SMTP (Simple Mail Transfer Protocol) is the standard protocol used to send emails over the internet. If you need to set up an SMTP hosting server for sending emails, this guide will walk you through everything from selecting a provider to configuring your SMTP server.
Choosing an SMTP Hosting Provider
You can either:
- Use a third-party SMTP provider (easier, recommended for businesses).
- Set up your own SMTP server (for full control).
Popular Third-Party SMTP Providers
| Provider | SMTP Server Address | Free Tier? |
|---|---|---|
| Google SMTP (Gmail) | smtp.gmail.com | Limited |
| SendGrid | smtp.sendgrid.net | 100 emails/day |
| Mailgun | smtp.mailgun.org | 5,000 emails/month |
| Amazon SES | Varies by region | Pay-as-you-go |
| Postmark | smtp.postmarkapp.com | Pay-as-you-go |
If you choose a third-party service, you will get SMTP login credentials from them.
Setting Up Your Own SMTP Server (Linux)
To run your own SMTP hosting, you need to install an SMTP server like Postfix, Exim, or Sendmail.
Install and Configure Postfix (Recommended)
Postfix is a popular SMTP server for sending emails.
Install Postfix
sudo yum install postfix -y # CentOS/RHEL
Configure Postfix
During installation, you will be prompted to choose a type of mail configuration. Select "Internet Site" and set:
- System mail name: yourdomain.com
- SMTP relay: None (if sending directly)
You can manually edit the configuration:
Add or modify:
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all
mynetworks = 127.0.0.0/8
relay_domains =
home_mailbox = Maildir/
Save and exit.
Restart Postfix
sudo systemctl enable postfix
Test SMTP Server
Install and Configure Exim (Alternative)
For CentOS/RHEL users, Exim is a great alternative to Postfix.
Install Exim
Enable Exim
sudo systemctl enable exim
Configure Exim
Edit the configuration file:
Modify:
Save and restart:
SMTP Authentication Setup
To prevent unauthorized usage, enable SMTP authentication.
Install SASL for Authentication
sudo yum install cyrus-sasl -y # CentOS/RHEL
Configure SASL for Postfix
Edit:
Add:
mech_list: PLAIN LOGIN
Restart SASL:
sudo systemctl enable saslauthd
Restart Postfix:
Setting Up SMTP with an Email Client
Once your SMTP server is running, you can configure an email client (e.g., Outlook, Thunderbird, Gmail) to send emails.
SMTP Settings for Email Clients
| Setting | Value |
|---|---|
| SMTP Server | mail.yourdomain.com |
| SMTP Port | 587 (STARTTLS), 465 (SSL), or 25 (Unencrypted) |
| Username | your_email@yourdomain.com |
| Password | Your SMTP password |
| Encryption | TLS or SSL |
Example: Configuring Outlook
- Open Outlook.
- Go to File > Account Settings > Add Account.
- Select Manual setup.
- Choose IMAP or POP.
- Enter:
- Incoming mail server: mail.yourdomain.com
- Outgoing mail server (SMTP): mail.yourdomain.com
- Username: Your full email address.
- Password: Your SMTP password.
- Click More Settings > Outgoing Server, check "My SMTP server requires authentication".
- Click Advanced and set:
- SMTP Port: 587 (TLS) or 465 (SSL).
Testing SMTP Configuration
Use Telnet
Type:
MAIL FROM: <you@yourdomain.com>
RCPT TO: <recipient@example.com>
DATA
Subject: Test Email
This is a test email.
.
QUIT
Use Swaks (SMTP Debugging Tool)
SMTP Logs & Troubleshooting
Check Postfix Logs
Check Exim Logs
Common Errors & Fixes
| Error | Fix |
|---|---|
| "Relay access denied" | Ensure SMTP authentication is enabled. |
| "Connection timed out" | Check if port 25, 465, or 587 is open in the firewall. |
| "Too many connections" | Set SMTP rate limits in /etc/postfix/main.cf. |
Secure Your SMTP Server
- Enable SPF, DKIM, and DMARC
- SPF Record (DNS TXT):
- DKIM Signing (Postfix):
- DMARC Policy (DNS TXT):
v=spf1 mx -allsudo apt install opendkim opendkim-tools -yv=DMARC1; p=none; rua=mailto:postmaster@yourdomain.com - Limit SMTP Relay to Specific IPs
Add to main.cf:
smtpd_client_restrictions = permit_mynetworks, reject_unknown_client - Enable SSL/TLS Encryption
Install Let's Encrypt SSL for secure email transmission:
sudo apt install certbot -y
sudo certbot certonly --standalone -d mail.yourdomain.com
- If you need quick SMTP hosting > Use SendGrid, Mailgun, or Gmail SMTP.
- If you want full control > Set up Postfix or Exim on your server.
- Secure your SMTP > Enable authentication, SPF, DKIM, and SSL.


