Picking the right port for an email transmission can make the difference between your email being delivered or not. Luckily, it’s not something you need to think about a lot as your email provider does it for you. And they care about the successful delivery as much as you do.
Sometimes, however, the default SMTP port might not guarantee the best delivery. This is when knowing what the alternatives are might really help. Let’s start then!
Let’s start with some definitions so it’s clear what we’re talking about.
SMTP (Simple Mail Transfer Protocol) is a technology that sends the huge majority of emails on the internet. It’s what moves the message from your email client through email servers to the recipient’s server. From there, it’s usually delivered to their client over a different protocol – usually IMAP or POP3.
Ports (not in a maritime sense) are communication endpoints commonly used to identify the exact location of an internet address. They’re a part of every domain address, even though they’re not visible to end-users. For example, to open an HTTP address you use port 80 and to get to an HTTPS address you need to use port 443.
When sending emails, SMTP first needs to direct them to a specific address on the internet for further processing. Each email is sent to a dedicated server and a predefined SMTP port.
Modern SMTP transmission can be broken down into two stages – email submission and relaying. Submission is, well, about submitting an email message to an outgoing server. SMTP Relay refers to the process of relaying a message between email servers (known as MTA), on the way to the recipient’s server. Frequently, different ports are used for each of these stages. We’ve covered SMTP Relay in detail in another article.
There are four of them that are or were considered standard at some point. These are ports 25, 465, 587 and 2525. Other ports can also be used for SMTP transmission but they’re not usually the first choice for Internet Service Providers (ISPs).
Among these four, 587 and 2525 are the more reliable options these days. To understand why, we need to look a bit back into history.
Port 25 is the oldest of all SMTP protocols. As a matter of fact, it was around since the very first days of email transmission. When RFC 821 was launched back in 1982, it established Port 25 as the default transmission channel for internet email. It remained omnipresent for all these years and even now is used for many transmissions.
Over time, though, 25 became a port for sending not only legitimate messages but also unwanted emails. Spammers were roaming freely, sending huge waves of spam over this somewhat ancient port. This, as a result, led to more and more hosting providers and ISPs blocking port 25 for email submission.
These days, port 25 is mainly used for SMTP Relaying – transmitting messages between different email servers. It’s not recommended to use for email submission unless you specifically manage your own mail server.
When sending emails this way, you may often hit an error that would indicate that port 25 is closed for email submission. Luckily, there are several alternative, more modern ports you can use freely instead.
It’s important to note that SMTP and its port 25 weren’t secure at the beginning. In 1995, SSL was introduced, establishing the first publicly available way to encrypt emails.
At that time, adding extra security to a port didn’t just mean some extra development. It required establishing an entirely new port for secured transmissions and having another one for plain text messages (port 25). It wasn’t just an SMTP thing – to this day, protocols such as FTP, IMAP and POP also use two different ports for encrypted and for plain text messages.
Port 465 was selected for use as the new, secure SMTP port for SSL while port 25 was tasked with relaying. Many platforms quickly migrated to port 465. Not long afterward, though, IANA (Internet Assigned Numbers Authority) reassigned this port for other uses, and recommended using other ports for secure transmission.
Due to this unusual move, many services that had just switched to 465 were left with a deprecated port. Others quickly adapted to use other ports. Even though port 465 was made redundant in 1998, you can still find many services using it today.
This is partly due to the fact that it was reinstated in 2018 with RFC8314. With this decision, IEFT wanted to “encourage more widespread use of TLS and to also encourage greater consistency regarding how TLS is used”.
Transmissions sent via port 465 rely on Implicit SSL. This means that upon the first connection to a server, a client will immediately negotiate an SSL connection. If either side of the transaction is not compatible, or if any errors occur, the transmission will not continue.
Another approach involves STARTTLS and Explicit SSL. Here, a plain text connection is established first which the STARTTLS command will try to upgrade to an encrypted one. If it fails for any reason, a plain text transmission will be used.
Read more about SSL, TLS, STARTTLS, and others in our other article about SMTP Security.
Port 465 is a reasonable approach if you explicitly want to use Implicit SSL. For Explicit SSL and STARTTLS, you might want to look into…
As we mentioned, in 1998 port 465 was made redundant for email transmission. With RFC 2476, internet authorities established port 587 as the standard.
At that time, traditional processing was split into two parts – submission and relaying. Relaying was entrusted to the good ol’ port 25 while all submissions were from now on to be directed via port 587.
To this day, port 587 is the default SMTP port for most services and should be used whenever you need a STARTTLS port. It’s supported also by nearly all ISPs.
To test if port 587 works on your server, run the following command in the terminal:
telnet example.com 587
The result of
250 <a href="https://mailtrap.io/blog/starttls-ssl-tls/">STARTTLS</a> will confirm that it’s ready.
Occasionally, port 587 might not be supported by an ISP or a hosting provider. Other time, running
telnet example.com 587 may simply yield errors.
This is when port 2525 may be helpful. It’s an alternative port to 587 that can also be used as an SMTP TLS port. It comes with the very same capabilities as its older brother port but has never been officially recognized by the internet authorities. Its lack of recognition doesn’t prevent it from working as a reliable alternative to 587, however. In fact, most ISPs also support it.
Whenever you’re given a choice, you should use 587 as the default SMTP port. It comes with TLS security and is the officially recognized port for email submission.
When 587 is not available or doesn’t work as expected, use port 2525 as an alternative. It comes with the same suite of features as 587 but has not been officially recognized.
If you want to use Implicit SSL, port 465 is also worth consideration.
For email relaying and relaying only, use port 25. Nothing has changed for the port since 1982 and it’s perfectly sufficient for these purposes.
SMTP Port 1025 is also sometimes recommended as an alternative for email submission. Select from ports 587 and 2525 if possible, and if neither works, use 1025 as the very last alternative.
Let’s now check the default SMTP server and ports for Gmail and other email providers. In some cases, you might be able to change the ports to your desired ones. When working with reputable providers, the ports displayed below are already well-tested and, as such, reliable.
When in doubt, contact your provider to learn what ports you can use when sending emails via their SMTP.
|Gmail||smtp.gmail.com||465 & 587|
|Yahoo||smtp.mail.yahoo.com||465 & 587|
This sums up our guide to the common SMTP ports. You should now have a fairly solid foundation of information about which ports can be used for what. If you’re planning on setting up your own SMTP server using this information, please check out our guide where we discuss the pros and cons along with the instructions for setting one up.
As always, once the SMTP connection is set up, don’t forget to test your emails before they’re sent to real users. One of the most commonly used tools for that is Mailtrap – a testing environment with an easy setup that lets you debug your workflows and quickly fix your outgoing emails.
Talk to you next time!
Thank you for reading our guide! The original blog post was published on Mailtrap Blog by Piotr Malek: https://mailtrap.io/blog/smtp-ports-25-465-587-used-for/