Setting up mail server on Contabo Server

Hello,

I recently had to set up a mail server. However, I encountered some issues which I would love to discuss here.

I had to use the Contabo server because Amazon is not enabling port 25 for my team on the AWS EC2 instance. After setting up the VPS on Contabo, connect to your server using the default username "admin" and the chosen password.

  • Change the server hostname to your domain
sudo hostname host.domain.tld
  • Install webmin Software and Postfix as the SMTP software
wget http://software.virtualmin.com/gpl/scripts/install.sh
sudo /bin/sh install.sh
  • Webmin configuration Your Webmin will be available on port 10000 of your domain or subdomain. Configure it using the guidance in the reference below this article.
  • Create a virtual server Create a virtual server and login into the newly created virtual using SSH. Grant Sudo privileges to the virtual server default user, if the username is "seunuser", then use the following command to grant the user sudo privileges from the "admin" user account.
sudo usermod -a -G sudo seunuser

The above user credentials will work, however, it is good practice to limit the user account to only what its expected to do "send email". Therefore, create a new user account with just an email priviledge option.

  • Create a user account email address Create an account as shown in the screenshot below and which will be used for SMTP login.

 Create User

  • Test the credentials Goto smtper.net and test the above credentials. If it works, then you can skip to the conclusion, else, check the next point.

  • Fix "Relay Access Denied" If you are getting "Relay Access Denied". Tail your error log using the following command

sudo tail -n 20 /var/log/mail.log

My error log looks like the screenshot below

error log

The following command helps in resolving the issue

rm -r /var/run/saslauthd/
mkdir -p /var/spool/postfix/var/run/saslauthd
ln -s /var/spool/postfix/var/run/saslauthd /var/run
chgrp sasl /var/spool/postfix/var/run/saslauthd
adduser postfix sasl

Credits

Then restart your server manually from the Contabo server.

  • Test the credentials Again

Your test should be successful now similar to the screenshot below.

SMTP Test

  • Conclusion I hope you find this helpful. Thank you for your time. Happy Coding