This post is part of a larger series about Building a Cloud at Home For Free as part of building scalable web applications from the ground up. This post starts at the point of setting the server up to be able to send emails. If you still need to setup your hypervisor and virtual server or install and configure Debian, check out my post Installing Virtualbox and Debian on Windows 10.
For the purposes of this post, I have chosen to install Postfix. It is a simple solution that works for what we need; sending emails directly from our server cluster. If you are trying to start an email company, this might not be the right option for you 😛
In order to install PostFix and the associated tools, run the following commands as root in debian;
Once installation is complete, you will receive the following prompt;
In this case, I choose “Internet Site.” You will then be prompted to enter the FQDN for the site.
There are lots of options for configuring Postfix. Check out this tutorial if you want more information about postfix…
First lets edit the config file with the command;
We need to make sure the following lines have the correct values. Make sure to replace yoursite.com with your fqdn.
Because we are changing the inet_interfaces, a simple reload of postfix is not enough. We need to stop and start it in order for this change to take effect.
Now we need to create a firewall rule to disable any connections to the smtp server not coming from localhost with the following command. Be careful as messing this up could be difficult to fix. What it does is create a rule to block any incoming connections to port 25 from our ethernet connection.
Now setup your webmaster address. Type the following command and you will see a list of aliases set to root. At the end, you will see root and your username. Change your username to the email you want these emails to be forwarded to, then save.
Type this command to save the changes to aliases.
Type the following two commands to reload the server to let the changes take effect. Normally this step is sufficient for most changes that need to take effect other than inet_interfaces changes.
Now it’s time to test the server…
You should see something like this;
Now send a test email! (These commands need to be entered one at a time)
You will then get something like “250 2.0.0 Ok: queued as EBECF8B” This means your message has been queued to send and will go out shortly! Type the command ‘quit’ to get out of telnet.
You should receive your email after just a moment!
If configured as specified, your new email server should be very secure and only accessible from localhost.