Configure postfix email server for your own domain with SMTP email client (part 1)
Own your email server for your domain
There are a lot of articles you can find about configuring email server or postfix. With the recent trend of cloud computing there are new services such as Amazon Simple Email Service and Mailgun.
You have your own domain, and you would like to have as many email accounts under your own domain as you need. There are a lot of good reasons to have it all in your control. You have already had a cloud server to run your own email server. That's all you will need. So why not? For example you can create an individual email address for each new website sign up.
The question is, how to setup a full functional email service, and make it as easy as using Gmail? Without the right setup the recipient email server will drop the email, mark it suspicious or deliver it into the spam folder.
Goals
We split the problem into subtasks below:
- To receive emails addressed to your domain and forward it to another email address;
- To send email that lands into recipient's inbox;
- To create as many email accounts as you wish;
- To connect your favorite email client to the email server to send emails;
- To use your Gmail account to receive emails to and send emails from your own domain;
- To block spam emails.
After all, you will have a flexible email system in your full control for 0 additional cost.
Part 2 of the article is available only to paid subscriber.
Non-goals
Other articles teaches you
- To configure your email server to send as your gmail.com account by signing in as SMTP client with password credentials.
- To send email by command line.
- To buy a cloud service to send batch emails.
Details
Receive emails and forward to another email address of your choice
You don't even need to setup your own email server because most domain registrars(e.g. name.com) offer email forwarding for free.
When you have already had your own email service running, the right word to lookup is /etc/aliases or alias_maps.
To send email that lands into recipient's inbox
The recipient's email server needs to know that the email is being sent from a valid email address. Or else a spammer can send emails from any domain and even to pretend to be your contacts!
99% of time people stop here because of the "AI" behind email anti-spamming. Only few understands the trick.
You may have heard about SPF, DKIM, and DMARC and find it too much for you. But the real trick is the PTR record!
You will need to config SPF records for your domain to specify who (domain or ip of the email server) is able to send email. DKIM is intended to use with third-party email server, and DMARC is intended to workaround DKIM on mailing list.
If your email server takes the domain name "email-sender.yourdomain.name", typically you have "a:email-sender" (alternatively "a:email-sender.yourdomain.name" / "a:email-sender aaaa:email-sender") in the SPF records, you need to point the PTR records of your email server's IPs to "email-sender.yourdomain.name".
Become a subscriber if you find this article helpful.
Install postfix
Goals listed above can be achieved with postfix. Installation is straight-forward on all major Linux distros.
Remaining setup
You will be able to figure it out by Google search or reading the manual of postfix.
Head to part 2 to save a few browser tabs. Save javascripts save the earth.