SMTP port explained: How to choose the right one

Mailtarget

A cover for a blog article titled "API key: SMTP port explained: How to choose the right one."

SMTP port is a crucial factor for email delivery. It determines how your email messages are transmitted from your email client or application to your mail server and then to the recipient’s mail server. Choosing the right port can make a difference in the speed, security, and reliability of your email service.

But what exactly is SMTP port and how do you choose the right one? In this article, we will explain what port is, why it matters, and how to choose the right one for your email service. We will also introduce you to mailtarget, a powerful email service for developers that lets you send emails with ease.

What is SMTP port?

SMTP (Simple Mail Transfer Protocol) is the standard protocol for sending and receiving email messages over the Internet. Port is the number that identifies the specific channel of communication between your mail client or application and your email server.

Port is usually specified in the settings of your mail client or application, along with other information such as your email address, password, and SMTP server name. For example, if you use Gmail as your email service, you need to enter smtp.gmail.com as your SMTP server name and 465 as your SMTP port in your mail client or application settings.

Why does SMTP port matter?

SMTP port matters because it affects the speed, security, and reliability of your email delivery. Different SMTP ports have different characteristics and implications for your email service. Here are some of the most common SMTP ports and their features:

  • Port 25: This is the default SMTP port that was assigned by the Internet Assigned Numbers Authority (IANA) in 1982. It is used for unencrypted communication between email servers. However, because of its widespread use and vulnerability to spam and malware attacks, many Internet Service Providers (ISPs) and Email Service Providers (ESPs) block or limit this port to prevent abuse and ensure security.
  • Port 587: This is the recommended SMTP port for submitting email messages from your email client or application to your email server. It was defined by the Internet Engineering Task Force (IETF) in 1998 as a replacement for SMTP Port 25. It supports encryption via Transport Layer Security (TLS) or Secure Sockets Layer (SSL), which means that your email messages are protected from eavesdropping and tampering while in transit.
  • Port 465: This is another SMTP port that supports encryption via SSL. It was originally introduced by Microsoft in 1997 as a non-standard SMTP port for secure communication between email servers. However, it was later deprecated by the IETF in 1998 in favor of SMTP Port 587. Despite this, some ESPs still use this port for backward compatibility or convenience.
đź’ˇ
SMTP determines the specific communication channel through which email servers send and receive messages, allowing proper routing and delivery of email.

How to choose SMTP port?

Choosing the right and secure SMTP port depends on several factors, such as:

  • Your email service provider: Different ESPs may have different requirements and preferences for SMTP ports. For example, Gmail requires you to use Port 465 or 587 with SSL/TLS encryption, while Outlook.com allows you to use Port 25, 465, or 587 with or without encryption. You need to check with your ESP to find out which SMTP ports they support and recommend.
  • Your email client or application: Different email clients or applications may have different capabilities and limitations for SMTP ports. For example, some older email clients or applications may not support encryption or newer ports. You need to check with your email client or application developer to find out which ports they support and require.
  • Your internet service provider: Different ISPs may have different policies and restrictions for SMTP ports. For example, some ISPs may block or throttle SMTP Port 25 to prevent spam and abuse, while others may allow it with some conditions. You need to check with your ISP to find out which SMTP ports they allow and recommend.

In general, the best practice is to use Port 587 with TLS encryption whenever possible. This ensures that your email messages are submitted securely and reliably from your email client or application to your email server. However, if this option is not available or compatible with your ESP, ISP, or email client or application, you can use SMTP 465 with SSL encryption as an alternative.

How mailtarget can help you send emails with ease?

mailtarget is a powerful email service for developers that lets you send emails with ease. With mailtarget, you don’t have to worry about SMTP ports, email servers, or email delivery. You can simply use our Email API, SMTP Relay, or Email SDK to integrate your email system with our platform and start sending emails in minutes.

mailtarget offers you many benefits, such as:

  • Sandbox Environment: You can test your email projects in a safe and isolated environment before going live. You can send unlimited test emails to any email address without affecting your reputation or quota.
  • Production Environment: You can switch to the production environment when you are ready to run your email projects live. You can send up to 10,000 emails per month for free and scale up as you grow.
  • Email Analytics: You can track and measure the performance of your email campaigns with our comprehensive email analytics. You can see how many emails are delivered, opened, clicked, bounced, or unsubscribed, and optimize your email strategy accordingly.
  • Email Templates: You can create and customize beautiful and responsive email templates with our drag-and-drop editor or HTML code. You can also use our pre-designed templates for various purposes and occasions.
  • Email Validation: You can verify and clean your email lists with our email validation service. You can reduce bounce rates, improve deliverability, and save costs by removing invalid, inactive, or risky email addresses.

How to configure your email client or application with mailtarget?

If you want to use mailtarget as your SMTP relay service, you need to configure your email client or application with the following settings:

NAME

VALUE

NOTES

Host

smtp-sandbox.mtrgt.net

-

Port

587

-

Encryption

STARTTLS

-

Authentication

AUTH LOGIN

-

User

[email protected]

-

Password

An API key with “Send via SMTP” permission

You can create and manage your API Keys from the app

Per-command Timeout

Minimum 60 seconds

See RFC-5321 for RFC recommended values

You can test your email client or application with mailtarget using swaks:

swaks --to [email protected] \
--from [email protected] \
--auth --auth-user= [email protected] \
--auth-password=API_KEY \
--server smtp-sandbox.mtrgt.net \
-tls

mailtarget strongly recommends using TLS with SMTP to protect your message content, recipient information and API keys in transmission. This includes API keys and any details such as recipient email addresses and message content.

If TLS is not supported by your application, mailtarget recommends using API keys with only the Send via SMTP privilege enabled. It is also good practice to regularly cycle your API keys to limit exposure of keys sent in the clear. API keys should be treated like passwords.

As stated in our Terms of Use, you “are solely responsible for all use of [your account].” That includes use of your account with API key compromised on an unsecured connection.

How to handle SMTP errors with mailtarget?

If you send mail through SMTP rather than REST, there are a few errors that are specific to mailtarget. The list below covers each of them, as well as what to do when you receive them. Please contact us for error messages that are not listed below.

Response

What it means

How to correct it

535 5.7.8 Sorry. *** No authentication type succeeded

There is some problem with the authentication credentials. API key, user name, etc.

Confirm that the API key has the Send via SMTP permission and the user name SMTP_Injection.

550 5.6.0 JSON parsing error in X-MT-ATTR

The X-MT-ATTR header is malformed in some way.

Fix the header’s json. The error message usually supplies additional details about the problem.

550 5.7.1 Unconfigured Sending Domain <admin.example.com>

The domain part of the “From” address isn’t a configured sending domain.

Use a “From” address that uses a configured sending domain. See Creating Sending Domains if you need to create a sending domain.

You can find more information about mailtarget’s SMTP in our documentation.If you want to send emails with ease, sign up for mailtarget today and try our sandbox environment for free. You can also switch to the production environment anytime and enjoy our free plan or upgrade to a premium plan that suits your needs.

(A.F)