Today I’m gonna talk about setting up SMTP authentication on a Linux VM. First, I grabbed a clean Linux box – I went with Ubuntu, but you can use whatever distro you like. I like Ubuntu because it’s user-friendly and has good community support. Once I had my VM up and running, the first thing I did was update the system. You know, the usual: sudo apt update
and sudo apt upgrade
. Gotta keep things fresh and secure, right?
Choosing the Mail Server
Next up, I had to pick a mail server. There are a few options out there, but I decided to go with Postfix. It’s known for being pretty solid and not too hard to configure. Sendmail is another popular choice. It is famous and powerful but it was a little harder to set up than I thought. So, I installed Postfix using sudo apt install postfix
. During the installation, it asked me a few questions about the type of mail configuration I wanted. I chose “Internet Site” because I wanted to send and receive emails over the internet.
Configuring Postfix
After Postfix was installed, I needed to configure it. I opened up the main configuration file, which is usually located at /etc/postfix/*
. I had to make a few changes here. I set the myhostname
parameter to my server’s hostname, and mydomain
to my domain name. These are important for identifying your mail server on the network.
Setting up SMTP Authentication
Now, for the main part – SMTP authentication. I wanted to set this up to prevent unauthorized use of my mail server. I mean, who wants spammers using their server? I added the following lines to the file:
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain =
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
These settings tell Postfix to use Dovecot for authentication and to enforce authentication for outgoing emails. Dovecot is another piece of software I installed earlier with sudo apt install dovecot-imapd dovecot-pop3d
. It’s an IMAP and POP3 server, but it can also handle authentication for Postfix.
Creating User Accounts
With the authentication settings in place, I needed to create user accounts. These are the accounts that will be used to authenticate with the mail server. I added a new system user with sudo adduser --disabled-password myuser
. Then I set a password for this user, which will be used for SMTP authentication.
Testing the Setup
Finally, I tested the setup. I used a mail client to send an email, making sure to use the correct SMTP settings and authentication credentials. I was so happy when I successfully sent my first email! And I checked the Postfix logs using tail -f /var/log/*
to see what’s going on behind the scenes. It’s always a good idea to check the logs to make sure everything is working as expected.
And that’s pretty much it! I now have a working Linux VM with SMTP authentication set up using Postfix and Dovecot. It took a bit of tinkering, but it’s definitely doable. This setup allows me to send about 100 emails a day for free, which is perfect for my needs. If you’re looking to set up your own mail server, give it a try. It’s a great learning experience, and it gives you full control over your email infrastructure.