Is SMTP Used Twice?

SMTP, or Simple Mail Transfer Protocol, is a key protocol used for sending and routing email messages between servers. It is one of the core internet protocols that powers email delivery globally.

A common question that arises is – is SMTP used twice when sending an email? The answer provides insights into how email routing works across networks.

Meta Description: SMTP (Simple Mail Transfer Protocol) is used to send messages between mail servers. It is used twice in email delivery – once from the sending server to relay server, and again from relay server to recipient server.

Is SMTP used twice?

How Email Routing Works

When you send an email, here is what typically happens:

  • Your email client connects to your outgoing mail server using SMTP and sends the message.
  • Your outgoing server relays the email via SMTP to the recipient’s incoming mail server.
  • The recipient’s server delivers the email to their inbox using protocols like POP3 or IMAP.

So SMTP is used two times:

  1. Between your outgoing server and the relay server.
  2. Between the relay server and recipient’s incoming server.

Key Takeaway: SMTP is used twice in email routing – from your outgoing server to the relay server, and from the relay server to the recipient’s incoming server.

Why Use a Relay Server?

Your email service provider maintains an SMTP server that you connect to for sending outward emails.

However, this SMTP server may not be able to directly connect to the recipient’s destination server. It has to route emails through an intermediate relay server that can communicate with the destination.

There are a few reasons relay servers are used:

  • Security – They protect internal email servers from public exposure.
  • Scalability – Relay servers handle spikes in traffic volume.
  • Deliverability – They optimize delivery success across different mail systems.
  • Spam Filtering – They add a layer of spam and virus scanning.

Key Takeaway: Relay SMTP servers act as secure intermediaries to route messages between domains and optimize email deliverability.

Typical SMTP Communication Flow

Here is how a typical SMTP conversation goes for sending an email:

  1. Your email client connects to your outgoing SMTP server using SMTP port 25.
  2. It initiates a handshake, introduces itself and submits the sender’s email address.
  3. The client provides the recipient’s email address and sends the message content.
  4. Your SMTP server adds headers to the message and routes it via SMTP to the relay server.
  5. The relay server does additional filtering, adds headers and relays the email to the recipient’s SMTP server.
  6. The incoming server deposits the email into the recipient’s mailbox from where they can access it.

Key Takeaway: SMTP is used between the sending server, relay server and receiving server to route messages across domains.

SMTP vs Mailbox Protocols

SMTP is only used for sending and relaying messages between mail servers.

Mailbox protocols like IMAP and POP3 handle storage and retrieval of messages for user mailboxes:

  • IMAP – Keeps messages on the server. Allows online access across devices.
  • POP3 – Downloads messages to a single client device like your desktop. deletes them from server.

So once the recipient’s SMTP server receives the message, it uses protocols like IMAP or POP3 to deposit it into the user’s mailbox for access via an email client.

Key Takeaway: SMTP routes emails between servers. Mailbox protocols like POP3 and IMAP handle storage and retrieval of user mailboxes locally.

SMTP Ports and Encryption

SMTP typically uses port 25 for plaintext communication.

However, most modern mail servers also support SMTP over Transport Layer Security (TLS) encryption using:

  • SMTP port 465 – SMTP over implicit TLS.
  • Submission port 587 – SMTP over explicit TLS.

Using TLS encrypts the SMTP session preventing snooping of messages. Verifying server certificates also protects against man-in-the-middle attacks.

Many email services now require SMTP encryption when sending outward mail. Port 25 may be blocked for open relay prevention.

Key Takeaway: SMTP transmission can be encrypted using implicit or explicit TLS to improve security. Most servers now require encrypted SMTP connections.

SMTP vs API Email Sending

Besides SMTP, some applications use API endpoints provided by email platforms to programmatically send emails.

For example:

  • SendGrid provides a Web API to send bulk emails from apps.
  • Mailgun has an API for sending mail from web forms.
  • Mailchimp and other marketing platforms have APIs to automate campaigns.


  • More flexibility for developers to integrate emailing within apps.
  • Better analytics and tracking of email performance.
  • Scalability to handle large volumes of mail.


  • Added complexity compared to SMTP.
  • Dependence on external provider APIs.
  • Less direct control compared to running your own SMTP server.

Key Takeaway: Email sending APIs provide an alternative to SMTP for developers, but come with pros and cons.

SMTP Server Software

To directly send mail using SMTP, you need to operate your own SMTP server. Here are some popular free and open source SMTP solutions:

  • Sendmail – A classic UNIX SMTP server that routes and delivers mail.
  • Postfix – A fast and secure SMTP and mailing list manager.
  • Mail-in-a-Box – A preconfigured SMTP+IMAP+Webmail server package.
  • Microsoft Exchange Server – Windows-based enterprise mail and collaboration server.
  • qmail – A secure, reliable SMTP server for Linux.

This gives you more customization control versus relying on a third party email provider. But you need to ensure sufficient reliability, delivery and security capabilities.

Key Takeaway: Running your own SMTP server gives more control but requires properly managing infrastructure, security, deliverability etc.

Troubleshooting SMTP Issues

Some common SMTP error scenarios and how to debug them:

  • Connection failures – Server is down, network problems, blocked ports, TLS issues. Check status, telnet to port 25/465/587, verify DNS.
  • Authentication failures – Invalid credentials. Double check username/password, check for 2FA.
  • TLS errors – Certificate issues, mismatch, expired or changed certificates. Validate certificates match.
  • Rejected recipients – Invalid email addresses, blocked domains, spam filters. Verify recipient addresses, whitelist servers.
  • Email sending limits – Volume caps, rate limiting triggers. Reduce sending rate, request higher limits.
  • Deferred or delayed mail – Transient network issues, server problems, queues piling up. Monitor queue length, check server logs.
  • Spam and delivery failures – Sender reputation issues like IP on blocklist, no SPF/DKIM records. Improve configurations and server hygiene.

Key Takeaway: Debug SMTP issues by inspecting error logs, server configurations, network connectivity, certificates, reputations and more.

Best Practices for SMTP Servers

Here are some best practices when running your own SMTP server:

  • Maintain uptime and fast performance to keep deliverability high. Monitor server health.
  • Enable domainkeys Identified Mail (DKIM) and Sender Policy Framework (SPF) to prevent spoofing.
  • Implement strong security and use encryption like TLS wherever possible.
  • Enforce authentication and implement controls like greylisting, rate limiting, etc.
  • Monitor queue length and retry failed deliveries to optimize throughput.
  • Establish PTR records and proper rDNS to improve reputation.
  • Block known spammer networks and enforce good neighbor policies by not allowing open relays.
  • Log monitoring and alerts to rapidly detect issues.

Key Takeaway: Operating a performant, secure SMTP server with good deliverability requires following best practices for reliability, security and reputation.


In summary, SMTP powers email delivery by routing messages between sending servers, relays and recipient servers. Using SMTP twice provides isolation between networks while enabling global message transmission.

TLS encryption, authentication and other mechanisms add a layer of security. APIs offer an alternative to SMTP for developers. Whether using SMTP directly or through providers, understanding how email gets transported can help troubleshoot issues.

Following reliability, security and deliverability best practices allows smoothly operating the critical SMTP infrastructure that keeps email working every day.

Key Takeaway: SMTP provides the backbone of reliable email routing across the internet. Using it properly and securing servers is key for maintainable email delivery.

Frequently Asked Questions

1. Does SMTP use encryption?

Yes, SMTP can use implicit or explicit TLS encryption for secure data transmission between mail servers. This prevents email snooping.

2. Does SMTP use port 25?

SMTP traditionally uses port 25 for plaintext communication. Ports 465 or 587 are used for encrypted SMTP over TLS.

3. Why are relay SMTP servers used?

Relay servers provide an intermediate hop for routing mail between domains securely and reliably. They optimize deliverability.

4. Is SMTP slower than an API?

No, SMTP is a very fast protocol. APIs may add overhead for authentication, serialization etc. so are not necessarily faster.

5. What ports does IMAP use?

IMAP uses port 143 for plaintext communication and port 993 for encrypted IMAP over TLS.

6. What are common SMTP server software?

Popular open source SMTP servers include Postfix, Sendmail, qmail and Microsoft Exchange Server. SMTP services are also offered by email providers.

7. How do I troubleshoot SMTP connection issues?

Check server status, telnet to the SMTP port, verify DNS records are correct, check for network problems and open port 25/465/587 if blocked.

8. How do I prevent my SMTP server from being on blocklists?

Follow best practices for security, authentication, not having open relays and good sending reputation. Maintain DNS records like SPF/DKIM.

9. What are some alternatives to SMTP for sending emails?

APIs offered by major email platforms provide an alternative to SMTP for developers building emailing capabilities into applications.

10. Does Office 365 use SMTP?

Yes, Office 365 has a built-in SMTP service for enterprise email routing. You can also configure it to use external SMTP servers.

11. Can I use Gmail’s SMTP server directly?

No, Gmail restricts its SMTP service to only its own users for sending mails. You cannot directly relay mails via the Gmail SMTP server.

12. What are common errors when connecting to an SMTP server?

Common errors include network connectivity issues, TLS handshake failures, authentication errors, recipient address rejections and hitting sending limits.

13. What tools can I use to test SMTP servers?

Telnet is commonly used to manually connect and test the basics. swaks provides an SMTP client for scripting tests. SMTPReply and MailTester help debug issues.

14. How do I optimize performance of my SMTP server?

Use a reliable platform, monitor queues, tune resources to handle load, enable compression, implement caching, throttle abusive clients and upgrade network capacity.

15. What are some key SMTP headers?

Important SMTP headers include From, To, Subject, Date, Message-ID, Received and Return-Path. Custom headers can also be added.

16. What are the alternatives to SMTP for receiving emails?

IMAP and POP3 allow retrieving emails from the mail server into a local mailbox. Some services provide webmail access via HTTP instead of a mailbox protocol.

17. Should I enable SMTP authentication?

Yes, requiring authentication over SMTP helps improve security and prevent spamming by restricting relaying to authorized users only. TLS should also be used.

18. How can I tell if an email was sent using my SMTP server?

Check the email headers. The Received header traces the hops the message took. Your server name will appear there if you sent the message.

19. What are best practices for preventing my emails going to spam?

Follow practices like properly configuring SPF, DKIM, DMARC records, not having unauthenticated relays, monitoring backscatter and maintaining uptime.

20. What are some alternatives to running my own SMTP server?

Using a third party email service provider relieves you of managing SMTP infrastructure. Another option is using API-based email sending platforms.


Leave a Comment