# How to Set Up SMTP Server in 2026

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "WebPage",
  "headline": "A Step-by-Step Guide to Set up an SMTP Server",
  "description": "Setting up your own SMTP server gives you complete control over your email-sending infrastructure. Follow the steps in this guide to set it up today.",
  "image": "https://res.cloudinary.com/mailmodo/image/upload/v1734341164/strapi/Setup_smtp_server_86fea55b46.png",
  "datePublished": "2024-12-16T09:27:44.691Z",
  "dateModified": "2026-01-27T02:26:52.413Z",
  "publisher": {
    "@type": "Organization",
    "name": "Mailmodo",
    "url": "https://www.mailmodo.com/",
    "sameAs": [
      "https://www.linkedin.com/company/mailmodo/",
      "https://www.facebook.com/mailmodo/",
      "https://www.instagram.com/mailmodohq/",
      "https://www.youtube.com/@mailmodo"
    ],
    "logo": "https://www.mailmodo.com/static/images/logo/logo-full.svg",
    "description": "Mailmodo is a complete email marketing platform that helps email marketers to create and send interactive emails to drive growth and engagement.",
    "address": {
      "@type": "PostalAddress",
      "addressLocality": "Lewes",
      "addressRegion": "DE",
      "postalCode": "19958",
      "streetAddress": "Mailmodo Technologies Inc. 16192, Coastal Highway",
      "addressCountry": {
        "@type": "Country",
        "name": "US"
      }
    },
    "contactPoint": {
      "@type": "ContactPoint",
      "email": "enquiries@mailmodo.com",
      "contactType": "customer service"
    }
  }
}
</script>

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "A Step-by-Step Guide to Set up an SMTP Server",
  "description": "Setting up your own SMTP server gives you complete control over your email-sending infrastructure. Follow the steps in this guide to set it up today.",
  "image": "https://res.cloudinary.com/mailmodo/image/upload/v1734341164/strapi/Setup_smtp_server_86fea55b46.png",
  "datePublished": "2024-12-16T09:27:44.691Z",
  "dateModified": "2026-01-27T02:26:52.413Z",
  "author": {
    "@type": "Person",
    "name": "Mashkoor Alam",
    "url": "https://www.mailmodo.com/guides/author/mashkoor-alam/"
  },
  "publisher": {
    "@type": "Organization",
    "name": "Mailmodo",
    "logo": {
      "@type": "ImageObject",
      "url": "https://www.mailmodo.com/static/images/logo/logo-full.svg"
    }
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://www.mailmodo.com/guides/setup-smtp-server/"
  }
}
</script>

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "@id": "#creator",
  "description": "Email marketing software to create and send interactive emails to maximize conversions and reinvent your user journey",
  "email": "support@mailmodo.com",
  "image": "https://www.mailmodo.com/static/images/og-image.png",
  "knowsAbout": "Email marketing",
  "legalName": "Mailmodo Technologies Inc.",
  "location": "United States",
  "logo": "https://www.mailmodo.com/static/images/logo/logo-full.svg",
  "name": "Mailmodo",
  "sameAs": [
    "https://twitter.com/mailmodo",
    "https://www.facebook.com/company/mailmodo/",
    "https://www.linkedin.com/company/mailmodo/"
  ],
  "url": "https://www.mailmodo.com/"
}
</script>

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {
      "@type": "ListItem",
      "position": 1,
      "name": "Home",
      "item": "https://www.mailmodo.com/"
    },
    {
      "@type": "ListItem",
      "position": 2,
      "name": "Guides",
      "item": "https://www.mailmodo.com/guides/"
    },
    {
      "@type": "ListItem",
      "position": 3,
      "name": "setup smtp server",
      "item": "https://www.mailmodo.com/guides/setup-smtp-server/"
    }
  ]
}
</script>

## Table of contents

- What is an SMTP server?
- Pros and cons of running your own SMTP server
- How to set up an SMTP server
- What's a better alternative?
- Final thoughts

If you’re one of those people who hate relying on third-party email providers to send emails, setting up your own SMTP server could be the solution you’re looking for. Third-party email service providers can be expensive and may not offer you the kind of control you would like to have over the specifics of the email infrastructure.

  

This guide will walk you through the steps you need to follow you seat up a local **SMTP server** for yourself on multiple operating systems, along with the pros and cons of having one.

## What is an SMTP server?

**An SMTP server (Simple Mail Transfer Protocol server) is an important component of email communication that manages the process of sending, receiving, and relaying emails. It allows the emails to be sent from the sender's email client to the recipient's email server.**

You can think of the SMTP server as your city’s post office. When you send a letter, it first goes to your local post office; then it travels to your recipient’s post office, who then delivers it to the right address.

## Pros and cons of running your own SMTP server

  

Before you invest time and resources to build an SMTP server, it’s important to think about the long-term advantages and disadvantages. Let’s explore them:

### Pros

-   **Highly customizable:** Setting up your SMTP server allows you to intricately customize your messaging preferences to suit your specific needs, such as sending limits, tracking pixels, and automatic responses.
    
-   **Predictable costs:** With an SMTP server, your costs are typically more predictable. Rather than being surprised by unexpected increases in pricing due to sending more emails, you can plan for consistent costs related to your server’s [infrastructure](https://www.mailmodo.com/guides/email-infrastructure/).
    

-   **Better control:** Being able to customize everything, you have full control over email limits and policies. This is something that you have no control over in third party email providers.
    

  

### Cons

-   **Need heavy maintenance:** Running your own SMTP server requires ongoing maintenance, such as software updates, security checks, and hardware management. This can be time-consuming and resource-intensive.
    
-   **Complex process:** Custom servers need permissions from ISPs, get their port enabled and have a static IP allocated in some cases. This makes the entire process pretty complex.
    

-   **Struggle with security:** To secure an SMTP server, you need to additionally install an [SSL](https://www.mailmodo.com/guides/ssl/) certificate and enable a firewall. Third-party solutions generally come with strong security measures that prevent any unauthorized breaches without you having to take any extra steps.
    

## How to set up an SMTP server

The process of setting up an SMTP server can be quite comprehensive and varies based on the operating system. Below, we’re discussing how you can set up a local SMTP server on different operating systems. It’s important to note that this is a basic set up and is usually used for testing purposes.

### 1. Setting up an SMTP server in Linux

Setting up an [email server](https://www.mailmodo.com/guides/email-server/) on Linux usually involves using Mail Transfer Agents (MTAs) software like Exim, Postfix, or Sendmail.

Since Exim and Sendmail have less secure architecture and are not beginner-friendly, we’ll be using [Postfix](https://www.postfix.org/start.html).

**Installation**

1. Start by opening up a Linux terminal.

![Setup smtp server Example 2.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735038509/strapi/Setup_smtp_server_Example_2_0fca954bf4.png)


2. Make sure your system is up-to-date with the latest APT packages by typing the command below. The response will show you the number of packages or applications that have updates available.

``` sudo apt update```

![Setup smtp server Example 3.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735038551/strapi/Setup_smtp_server_Example_3_2995f2cc0c.png)

3. Next, check if Postfix is installed on your computer by typing the following command:

```sudo apt-cache policy postfix```

![Setup smtp server Example 4.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735038583/strapi/Setup_smtp_server_Example_4_b12ea3e7a3.png)

If the response says ```installed: (none)```, it means that the application isn’t installed.

4. In that case, you can easily install it with the following command:

```sudo apt install postfix -y```

  

5. During the installation process, choose the Internet Site option for the mail setup.
![Setup smtp server Example 5.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735038629/strapi/Setup_smtp_server_Example_5_4b4d989a92.png)
![Setup smtp server Example 6.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735038648/strapi/Setup_smtp_server_Example_6_3d19cbe45e.png)

6. Now, enter your website’s fully qualified domain name (FQDN). For example, it could be something like mail.example.com.

![Setup smtp server Example 7.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735038677/strapi/Setup_smtp_server_Example_7_c4bc6e19a2.png)

![Setup smtp server Example 8.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735038709/strapi/Setup_smtp_server_Example_8_52d1349c63.png)

**Configuration**

7. Once Postfix is installed, it is time to set up your Postfix service. First, enable it to start automatically during system boot by giving the following command.

```sudo systemctl enable postfix```

![Setup smtp server Example 9.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735038744/strapi/Setup_smtp_server_Example_9_d1f48c22f5.png)

8. Next, start the software by typing:

```sudo systemctl start postfix```

![Setup smtp server Example 10.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735038773/strapi/Setup_smtp_server_Example_10_8649fdd581.png)

  

It won’t give you any response after this, but you can then check the status using the following command:

```sudo systemctl status postfix```

![Setup smtp server Example 11.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735038809/strapi/Setup_smtp_server_Example_11_2d4a1a429e.png)

It’ll show you the status as ‘Active’ if it’s running. Also, you won’t be able to give any other command in the status display. Press q to exit this status display.

9. Before configuring your SMTP server, back up your main.cf file, as you will be editing it a lot.

```sudo cp /etc/postfix/main.cf /etc/postfix/main.cf.backup```


10. Next, run the following command to open the main.cf file:

```sudo nano /etc/postfix/main.cf```

11. In this file, you’ll need to make a couple of changes:

-   First, find the line that says ```inet_interfaces = all``` and change it to:
    

```inet_interfaces = loopback-only```

  
![Setup smtp server Example 1.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735039019/strapi/Setup_smtp_server_Example_1_04d4912145.png)

![Setup smtp server Example 13.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735039039/strapi/Setup_smtp_server_Example_13_0a329be6c9.png)



-   Locate the ```mydestination``` line and edit it to include all your domain names. It should look something like this:
    

```mydestination = $myhostname, localhost.$example.com, $example.com```

12. Once you've finished editing, press  Ctrl + X to exit Nano. It will prompt you to save the changes; simply  press Y to confirm.

13. To apply the changes, return to the main terminal window and restart Postfix by typing:

```sudo systemctl restart postfix```

14. Then check whether Postfix is running or not post-restarting by typing:

  

```sudo systemctl status postfix```

![Setup smtp server Example 14.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735039082/strapi/Setup_smtp_server_Example_14_fb415a83d4.png)

**Testing**

15. Now that everything’s set up, let’s make sure it’s working. First, install Telnet, a command-line tool used for connecting to remote servers. You can do that using the following command:

```sudo apt-get install telnet```
![Setup smtp server Example 15.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735039138/strapi/Setup_smtp_server_Example_15_ebbfe9fee8.png)


16. Open the  Terminal and run this command to connect to your remote SMTP server:

```telnet localhost 25```

If the connection is successful, it’ll the response will say ```Connected to localhost```

![Setup smtp server Example 16.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735039166/strapi/Setup_smtp_server_Example_16_fa84586bdd.png)

  
  

17. Finally, send a test email by typing the following commands— one at a time. Press  Enter after each one to get a response for your command. Note that 250 stands for confirmation or Ok.

So, this is what the commands would look like:

```

HELO example.com

250 mail.example.com

MAIL FROM:<sender@example.com>

250 message ID OK

RCPT TO:<recipient@example.com>

250 message ID OK

DATA

354 End data with <CR><LF>.<CR><LF>

```

Tip: This means the server is ready to accept the message content.

```

Subject: Test Email

This is the body of the first email to my test server.

.

250 OK, queued as 12345.

QUIT

221 message id Bye

```

![Setup smtp server Example 17.png](https://res.cloudinary.com/mailmodo/image/upload/f_auto,q_100/v1735039252/strapi/Setup_smtp_server_Example_17_17dea88620.png)

When you run the above commands and see the same output as mentioned, it indicates your SMTP server is up and running on the Linux system.

### 2. Setting up an SMTP server in Windows

For setting up an SMTP server on Windows, you’ll need to install a third-party tool like Amazon SES, MailEnable, or hMailServer. In this tutorial, however, we’ll be using hMailServer, as it’s free and easy to set up.

**Installation**

1. Download the  hMailServer software from the [official website](https://www.hmailserver.com/).

2. Follow the onscreen steps to install your software.

Keep in mind:

-   On the Select Components window, select the Full Installation option and make sure both Server and Admin are ticked.
    
-   On the Select Database Server window, opt for the built-in database engine option.
    
-   In the hMail Server Security window, pick a strong but easy-to-remember password.
    

**Configuration**

1. Launch the hMailServer Administrator. On your first run, you will be asked to enter the password you set during installation.

2. Click on the Connect button on the top right to access the hMailServer Administrator console.

3. Click on Domains from the sidebar on the left. This will open a modal on the right.

4. Select the Add Domain button to create a new domain. Here, enter your domain name and click Save. You can now see your domain listed on the left sidebar.

5. Under your Domain thread on the left, click on Accounts. Here, provide your email address and create a new account.

Tip: Your email address format should be something like this: user@example.com

6. Tap Save to finish setting up the account.

7. Now, go to Settings > Protocols > SMTP from the left sidebar. Uncheck POP3 and IMAP and click Save.

8. Go back to the Settings thread and select the logging option. Here, check the Enable box at the top, followed by selecting Application, SMTP, and TCP/IP. Then click Save.

9. Now, go back to the Settings thread, but this time, select Advanced > IP Ranges. Here, remove the internet range.

10. Then, click on MY COMPUTER range and uncheck the boxes for POP3, IMAP, anti-spam, anti-virus, and external to external email addresses and tap Save.

11. The next step is to figure out how you want your emails to be sent. You have two options.

-   Activate hMailServer as a relay server:
    

1.  Go to Settings > Protocols > SMTP from the left-hand side.
    
2.  Go to the Delivery of Email tab.
    
3.  Fill out the SMTP relayer portion with details like remote host name, TCP/IP port, authentication, and security settings.
    

-   Setup hMailServer as a mail server:
    

1.  Go to Settings > Protocols > SMTP and open the Delivery of Email tab.
    
2.  Leave the SMTP relayer section blank.
    
3.  At the top, fill in the Local hostname text field with your IP reverse lookup hostname.
    

Tip: You can use an [IP reverse lookup](https://mxtoolbox.com/ReverseLookup.aspx) tool to find the accurate hostname.

Important Note: With this setup, emails go directly to the recipient instead of passing through your email server. As a result, no copy is saved on the server and has a higher chance of being flagged as spam. Set up an SPF record to help prevent this.

12. Restart your hMailServer by going to the Windows Services. You can find it easily by pressing Windows+R, typing ```services.msc```, and hitting Enter.

**Testing**

13. Open your email client (e.g., Outlook) and create a new account. All you need to do is enter your email address, password, and the incoming and outgoing mail server details.

14. Type an email and try to send it.

15. If the test email doesn’t send successfully, review your SMTP settings. You can use the hMailServer built-in diagnostic tool to do this:

1.  Go to hMailServer Administrator > Utilities > Diagnostics.
    
2.  Choose your domain.
    
3.  Click Start. The diagnostic tool will automatically check for issues like DNS or mail ports and provide recommendations for any necessary fixes.
    

### 3. Setting up an SMTP server in MacOS

Postfix is usually pre-installed on macOS, but if you need to ensure it is installed, you can use the built-in Homebrew package manager.

**Installation**

1. Launch the Terminal app from the Applications > Utilities folder.

2. Run the following command to check if Postfix is already installed:

```postfix -v```

Tip: If installed, this command will display your postfix version information.

3. If it’s not installed, you can install it using Homebrew with the command:

```brew install Postfix```

**Configuration**

4. Once Postfix is installed, open the Postfix configuration file using a text editor like Nano:

```sudo nano /etc/postfix/main.cf```

5. Modify the following parameters in the main.cf file:

-   myhostname: Enter the name of your computer (e.g., myhostname = your.hostname.com).
    
-   mydomain: Set your domain name (e.g., mydomain = yourdomain.com).
    
-   mydestination: Set the local domains Postfix will handle (e.g., mydestination = $myhostname, localhost.$mydomain, localhost).
    
-   relayhost: relayhost = [smtp.yourprovider.com]:587
    

For enabling SASL authentication:

-   smtp_sasl_auth_enable = yes
    
-   smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    
-   smtp_sasl_security_options = noanonymous
    

To enable encryption:

-   smtp_tls_security_level = encrypt
    
-   smtp_tls_CAfile = /etc/ssl/cert.pem
    

6. After making these changes, press CTRL+X, then press Y to confirm, and hit Enter to save.

7. To secure your SMTP server, create a SASL file for storing your credentials. Run the following command to create the password file:

```sudo nano /etc/postfix/sasl_passwd```

Tip: Add your SMTP server credentials in this format:

[smtp.yourprovider.com]:587 username@gmail.com:yourpassword

8. You must secure the password file by setting the file permissions feature. Use the following command for that:

```sudo chmod 600 /etc/postfix/sasl_passwd```

9. Postfix needs a hash database to read the password file. Create it by running:

```sudo postmap /etc/postfix/sasl_passwd```

10. Finally, restart Postfix to apply your changes by typing:

```sudo Postfix reload```

**Testing**

11. To check if everything is working, send a test email from the Terminal. Use this command:

```

echo “Test email body” | mail -s

“Test Email Subject”

recipient@example.com

```

12. Check your inbox to ensure the message was delivered successfully.

13. If not delivered, check your email logs (located in /var/log/mail.log) for any issues or errors.

tail -f /var/log/mail.log

## What's a better alternative?

Setting up your own SMTP can take a lot of time and effort, particularly if you’re not a techie. It might even require you to hire an expert to do this for you. There are also multiple aspects to look into and multiple things to tweak and fix once in a while.

A much simpler option is to go with a third-party email service provider or [email marketing platform](https://www.mailmodo.com/guides/cheap-email-marketing/) that takes care of all these requirements and provides additional benefits. You can choose Mailmodo as a low-cost, highly functional alternative to this.

<div class="inline_cta"><div class="ctaBox"><div class="leftdiv"><p>Start sending emails with Mailmodo today </p><div class="button_container"><a href="[https://manage.mailmodo.com/auth/signup?utm_content=inline-cta-s](https://manage.mailmodo.com/auth/signup?utm_content=inline-cta-s)"><button class="primary_button">Try Mailmodo for free</button></a></div></div><div class="rightdiv"><img src=https://res.cloudinary.com/mailmodo/image/upload/v1712747193/strapi/Group_1110165064_1_57b7027899.png width="290" height="230" alt="cta-img"/></div></div><div class="gradient"></div></div>

## Final thoughts

Whether you are a Mac, Windows, or Linux user, now you have all the instructions to set up your own **SMTP server**.

While having your dedicated SMTP server makes it easy to send dozens of emails, an email marketing tool like Mailmodo can readily set your email-sending infrastructure, minimise deliverability issues, and protect your address against those tricky email-based attacks.

So, give it a try today.

## Frequently Asked Questions

### What is the difference between SMTP and IMAP/POP3?


SMTP is used for sending emails, while IMAP and POP3 are used for receiving them. For example, when you send an email through Gmail, SMTP sends it out. On the other hand, when you check your inbox, IMAP or POP3 brings the email to your device.

### Can I set up an SMTP server without a domain?

Yes, you can set up an SMTP server without a domain, but it is not recommended. Without a domain, your emails may not look credible and could get flagged as spam by other email services.

  

### What ports are commonly used by SMTP servers?

SMTP servers use ports 25, 465, and 587. Port 25 is used for sending emails between servers but can get blocked to stop spam. When that happens, port 465 (with SSL) or port 587 (with STARTTLS) is used for secure and safe email sending.

  

### Is it possible to set up an SMTP server on macOS?


Yes, you can set up an SMTP server on macOS using third-party software like Postfix or Mailspring. While macOS doesn't include Postfix by default, with Homebrew, you can install it easily.

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
    {
      "@type": "Question",
      "name": "What is the difference between SMTP and IMAP/POP3?\n",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "SMTP is used for sending emails, while IMAP and POP3 are used for receiving them. For example, when you send an email through Gmail, SMTP sends it out. On the other hand, when you check your inbox, IMAP or POP3 brings the email to your device."
      }
    },
    {
      "@type": "Question",
      "name": "Can I set up an SMTP server without a domain?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Yes, you can set up an SMTP server without a domain, but it is not recommended. Without a domain, your emails may not look credible and could get flagged as spam by other email services.\n\n  "
      }
    },
    {
      "@type": "Question",
      "name": "What ports are commonly used by SMTP servers?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "SMTP servers use ports 25, 465, and 587. Port 25 is used for sending emails between servers but can get blocked to stop spam. When that happens, port 465 (with SSL) or port 587 (with STARTTLS) is used for secure and safe email sending.\n\n  "
      }
    },
    {
      "@type": "Question",
      "name": "Is it possible to set up an SMTP server on macOS?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "\nYes, you can set up an SMTP server on macOS using third-party software like Postfix or Mailspring. While macOS doesn't include Postfix by default, with Homebrew, you can install it easily."
      }
    }
  ]
}
</script>

---

**Author: Mashkoor Alam**

Mashkoor has always been passionate about writing. He used to write short stories on his blog before he started writing for SaaS companies years back. He aspires to have a book under his name.

