SMTP Server Setup, Usage , and Best Practices

Ever wondered how Emails actually work, When you send an email and within a few seconds they are in your recipient’s Inbox, the technology behind how this happens is Simple Mail Transfer Protocol ( SMTP ). How emails are stored on the server once received using IMAP/POP3 Server is a story for a different time, for now, we will cover SMTP and by end of the article, we hope you have a complete understanding of the STMP Protocol, SMTP Servers, Common options and how to ensure your emails done land up in SPAM.

What is SMTP ?

Simple Mail Transfer Protocol ( SMTP ) is the protocol used to Send Emails, it defines a common standard so that any SMTP server can communicate with any other SMTP Server or POP3/IMAP server on the internet and they understand each other. You can say it ensures that different entities involved in the transfer of Emails speak a common language.

What is a SMTP Server ?

The SMTP protocol needs to be made available by an application, this application that responds to the SMTP requests for those who wish to send Email or relay EMail is called a SMTP Serve/SMTP Relay. You can break it into two types as given below, both are mostly the same other than the a minor difference –

  • SMTP Server : It is the same thing as a SMTP relay but mainly used when the receiver domain is the same as the server domain. These are usually used with free email services like gmail.com , yahoo.com.
  • SMTP Relay Server : This is also a Server, but this term is used when the source email and destination email domains are different from the SMTP server domains. An example can be SendGrid or SendInBlue who offer these.These servers are mainly routers for the mail.

Fake SMTP Servers : – These Servers are mainly used for testing by developers, they basically are catch-all servers that allow users to see how the Email will look on the recipient end without actually sending any Email. You can either install local application like MailHog or MailCatcher or use a cloud on provided like Mailtrap or Our local tool.

How SMTP Works ?

Below is a common guide to how the process of Sending Emails work with the SMTP.

  • A user wanting to send an email from say [email protected] to [email protected] uses his Email client to draft an Email with Subject and Body and press Send.
  • Once the user presses send the Email client will connect to the configured SMTP server for now let’s assume it to be smtp.source.com . The client and SMTP server do a handshake and if authorization is required then the client will provide credentials for the same.
  • After handshake the Email Client sends the Receivers address which in our case is [email protected] , subject and the body.
  • If it had been our user had been sending to a someone in the same domain then our server will simply forward it internally to the local recipient server.
  • Next the SMTP server using a DNS request for MX records finds out the recipients IP or domain address where his SMTP server is running.
  • Next it connects to the receivers SMTP address and tried to deliver the email.
  • The recipients Email Server verifies if it can handle the Email being forwarded to it. And if all is well then it forwards this to the incoming IMAP or POP3 Server.

Common SMTP Port and Address

In most cases the SMTP address will be a prefix of mail or smtp in front of the domain to which you are trying to connect to. Also these are specified by the Mail Exchange (MX) records in the DNS which direct a client to the mail server which is supposed the handle how Email messages are to be routed.

To find the address of the SMTP server you can use the dig command

Then you can use the dig command to find the IP address if required

Things are not so simple with the port which to connect to, Servers and relays usually have a set of different ports which you can connect to, each has come into being overtime to fulfill specific requirements.

SMTP Port

Port NumberDescriptionInformation
25Standard SMTP PortIt should mainly be used for Email Relay
465Deprectared SMTP PortWas for secure SMTP, Used SSL for encryption. Avoid usage.
587Modern Secure SMTP PortMost moden Email Clients will use this , it uses TLS Encryption.
2525Alternative Non Standard SMTP PortThis is used as an alternative to 587 incase its blocked.

In most cases you will be using the Port 587 for your needs.

Common SMTP Server Names

Common addresses for SMTP servers start with smtp. or mail. with the domain name, Some might have an IP address also. We have listed a few common ones with their details below –

Service NameSMTP ServerPort
Googlemailsmtp.gmail.com587
Outlook.comsmtp.live.com587
Office365.comsmtp.office365.com587
Yahoo Mailsmtp.mail.yahoo.com465
Yahoo Mail Plusplus.smtp.mail.yahoo.com465
Yahoo UKsmtp.mail.yahoo.co.uk465
Yahoo Deutschlandsmtp.mail.yahoo.com465
Yahoo AU/NZsmtp.mail.yahoo.com.au465
O2smtp.o2.ie25
O2.uksmtp.o2.co.uk25
AOL.comsmtp.aol.com587
AT&Tsmtp.att.yahoo.com465
NTL @ntlworld.comsmtp.ntlworld.com465
BT Connectpop3.btconnect.com25
BT Openworldmail.btopenworld.com25
BT Internetmail.btinternet.com25
Orangesmtp.orange.net25
Orange.uksmtp.orange.co.uk25
Wanadoo UKsmtp.wanadoo.co.uk25
Hotmailsmtp.live.com465
O2 Online Deutschlandmail.o2online.de25
T-Online Deutschlandsecuresmtp.t-online.de587
1&1 (1and1)smtp.1and1.com587
1&1 Deutschlandsmtp.1und1.de587
Comcastsmtp.comcast.net587
Verizonoutgoing.verizon.net465
Verizon (Yahoo hosted)outgoing.yahoo.verizon.net587
Zoho Mailsmtp.zoho.com465
Mail.comsmtp.mail.com587
GMX.comsmtp.gmx.com465
[email protected] by USA.NETsmtp.postoffice.net465

Bulk SMTP Server provider settings

What happens if you want to send more than a few Emails, say 10000 K emails then you will need something like a Bulk SMTP relay, they will also provide you API and other features like Delivery tracking, Open rates etc. Also help you send the Emails quite fast as SMTP as a protocol is a bit slow.

If the number is not very large then you can use our listing for Free SMTP Servers providers to make a choice.

If you want to send an email to your large userbase or maybe for Email marketing we have given pricing below with various providers listed.

VendorFree / MonthDaily LimitPaid plansComments
SendInBlue9000300$25 for 10k to $499 for 1 MillionBest Free
TurboSMTP600020014.95 for 50k to 979.95 for 2 Million. 6000 / month for 12 months
Alibaba Direct Mail6000200.00029 per 1000 Emails
PepiPost3000100$25 for 150k to 445 for 2 Million
SendGrid3000100$14.95 for 50K emails to $749 for 150K
SparPost3000100$20 for 50K to $525 for 1M
Elastic Email3000100Costing like Amazon SESLow cost paid option
Amazon SES62000.0001 for 1000 EmailsOne of the Cheapest , Free if sent from AWS EC2 server
GMail15000500Gsuite is the premium optionDomain will be gmail.com , Can lead to account suspension.

Using a SMTP server with WordPress

WordPress powers almost 40% of the sites on the internet, by default it uses PHP Mail to send transactional emails which inturn if not configured uses sendmail , This can be a hit or miss in the case when delivery is concerned, so we recommend using a WordPress plugin which can use SMTP Settings or use SMTP API for the same.

By default, WordPress uses PHP mail to send an email, if configured correctly it is sufficient, but in most cases, it’s easier to use third-party Service as most shared hosts do not allow direct console access to check what is going on and your Host IP might have been blacklisted due to SPAM as there may also be other users on the Server ( Incase of Common Shared Hosting) who might not behave and cause your IP to be blacklisted. By being blacklisted we mean that your server’s IP is put in a global list of known spammers, which makes it even harder for your Mails to get through, you can check your status here.

For WordPress we recommend the Wp Mail SMTP Plugin, it’s easy to configure, set up, and supports a lot of different vendors including Gmail, there is also an option to log all sent emails. The free plan should be sufficient for most users.

You can easily install it from inside WordPress or even download it from WordPress’s website. It has a premium plan, but free should be good enough for most users.

Setup self-hosted SMTP Server on Linux

Quick MTA Comparison , we will choose Postfix as we will be working with linux –

if you are... qmail Exim Sendmail Postfix Notes
Inexperienced
0 3 1 3 Exim and Postfix have good docs and clear examples
Worried about security
3 2 0 3 Postfix is secure and modern; qmail is secure but very old and cranky; Exim is secure to different criteria (read above.)
Relying on Sendmail milters
0 1 3 2 Postfix can run milters; can use equivalent Exim routers/filter script
Wanting minimum hassle
0 3 0 3 Sendmail has some easy front-ends, but the deeper you go the worse it gets. Postfix and Exim are more predictable.
Resource-constrained
3 2 1 2 See Embedded Application below for other comments
On Windows
0 2 3 0 Sendmail has a native Windows port; Exim is in the Cygwin distro
Needing commercial support
1 3 3 3 There are competent companies for all MTAs; qmail is inherently less supportable being so old

Postfix is a Mail Transfer Agent (MTA) that can act as an SMTP server or client to send or receive email. It is easy to set up and configure and we ourselves use it for most of our needs , it can also be setup to act as an intermediary to forward emails through third-party emails services. We will only cover basic setup and send your first email.

The most simple setup consists of installing postfix and you should be good to go.

Such a bare-bones setup will work technically but your Emails might land in SPAM, to cater to this and ensure better email deliverability, we have another guide where we add the other requirements like DKIM or SPF which are needed to make sure your Emails go through. But still, unless there is a very good reason we do not recommend to run your own Email Server.

This process assumes that you have a new installed Ubuntu 20.04 and you can work with command line Linux , if not we recommend using one of the existing SMTP Providers. We will set up postfix on Ubuntu 20.04 server and send an Email using it to our very own dummy service for testing to see if it works.

To begin we will issue the update cache command for apt package manager

sudo apt update

Next we will install postfix using the following command –

sudo apt install postfix

The installation will open up a bunch of prompts please make the following selections –

  • General type of mail configuration? : For this, we will choose an Internet Site since this matches our infrastructure needs.
  • System mail name: This is the base domain that will be used to send an email if no sender domain is specified by the user. So if you send an email from say user1 and no domain is specified this will be postfixed to the email. So if example.com is given, it will send email from [email protected] .

That should take care of the basic config. For a complete setup please follow our mail-server setup guide. Now port 25 should be available, you can check f its open by using any of the commands –

What we are looking for something like this

master 2575 root 13u IPv4 30244 0t0 TCP *:25 (LISTEN)
master 2575 root 14u IPv6 30245 0t0 TCP *:25 (LISTEN)

If you even need to reconfigure the setup simply run the command –

We are all set our SMTP server should be up and running. Next, we can be sending an Email to some users on the internet or maybe to catch all email to test things.

Using a SMTP Server

Usually, an Email client is the most common way most of us will interface with an SMTP server , but you can also directly interact with it using telnet. We will start with this method as it is just plain cool.

Send mail using telnet in linux

Connect to your local SMTP Server by entering the following command –

You will see something like this –

If you are not able to connect make sure postfix is running and check port 25 is open.

Now lets send a email to say [email protected] ( catch all email ).

Go check if the Email is received in the inbox for [email protected], or if you used a different recipient can check it in its inbox.

Send Email from linux command line

On linux we can use the sendmail command to send Email quickly.

I hope you like my article, if you feel i missed some points or was wrong somewhere then please do let me know and I will update it here.

Leave a Reply

Your email address will not be published.