<< Go back to Part 1 (If you haven’t already read it)
Wait- the rest is easy?
So you’ve got your very own server, a domain that points to it, and a way to connect! We’re almost done believe it or not. Instead of telling you how to configure every little piece yourself, I’m going to provide you with a bash script that will do it all for you. Essentially you just have to download the script, and then it will build the amazon ec2 mail server after you change a couple of important variables.
IMPORTANT* If you are an experienced user and wish to suggest changes to the script on github, feel free to do so;
My goal is to keep the script functional and also improve the integrity of the setup it provides whenever possible. If you don’t want to make the changes yourself but wish to point out something, you can comment below this post- I will read and respond to as much as I can and also work on making fixes. A note of honesty from me- it will be quicker to implement fixes / changes if I can just review them and commit versus writing them myself.
Now that you know how to help me help you, let’s continue!
Step 1: Preliminary Server Setup
If you haven’t already switched over to your server, login via ssh.
Currently you will be a user named ec2-user. We need to upgrade your privileges before continuing. To become the root user, type the following command;
Now let’s install emacs, a powerful text editor and git, the tool we’ll use to grab the script. Then, make a directory to store the mail script in and download it.
yum install emacs git -y git clone https://github.com/Avix101/Mail-Server-Script.git cd Mail-Server-Script ls (to display contents)
Now that you have the script, we have to adjust a couple of variables before running it. If you only have one domain that you want to receive mail for, only put one between the quotes of virtual_mailbox_domains. If you have multiple, add them all delimted by a single space, and make sure the one you want to use to connect via http and https is the first domain.
emacs super.sh #### In this file change virtual_mailbox_domains="yourdomain.com secondDomainIfYouHaveOne.com ..." (Only enter one if you only have one) default_password="whateverYouChoose"
Step 2: Running the Script
Once done, type ctrl+x -> ctrl+s to save, and ctrl+x -> ctrl+c to exit. At this point everything should be ready to go. Just type the following command, sit back, and watch the magic. The script usually takes about 3-4 minutes to complete if you have a stable internet connection.
Once done (assuming no error messages popped up) the server should be completely configured! You should be able to log into https://yourdomain/mail (you won’t have valid certs installed at this point, so expect the browser to say it’s an untrusted connection) with the default account: firstname.lastname@example.org pass=default_password
Step 3: Tell Amazon to lift Email Sending Limitations
In order to send email from an Amazon ec2 instance, you’ll have to fill out a request to have the email sending limitations removed from your aws account. The form can be found here. Type in your email (not the one you just setup), and tell them why you want to have the limitations removed. Explain that you are trying to build a personal mail server with packages like Postfix and Dovecot. Then, supply them with the elastic IP address that you are using for your server. Where it asks for a Reverse DNS Record, type mail.yourdomain.com. If you want to clarify, in the case description explain that your domain is yourdomain.com and mail that you send is being flagged as spam, so you would like to setup a reverse DNS record for mail.yourdomain.com. This process will take some time, but upon completion you should be all set to go. The only additional thing you may want to look into is obtaining certificates for your site. If you are interested in doing that and need help, keep an eye out for part 3 of this series, or tell me that you need help with it, in which case I’ll write part 3 faster.
*IMPORTANT NOTICE (9/21/16):
DO NOT USE THIS SCRIPT FOR ANYTHING BUT A NEW INSTANCE. Or just be warned of the risks. Use snapshots to ensure the safety of your content.
UPDATE: I have been able to successfully install the script on a new instance after making a few fixes. We are back on a stable release. The script should complete successfully if all instructions are followed.
Test Parameters (9/22/16):
|Script runs on a brand new Amazon Linux instance||Passed|
|Script runs without throwing errors||Passed|
|Script runs without throwing warnings||– (Some inconsequential Dovecot semantics)|
|No extra steps required outside of the guide||Passed|
|Apache starts and /mail is accessible||Passed|
|Sent and received email from a Google account to new server||Passed|
|Detected default spam flag and placed in junk folder||Passed|
Please enjoy, and continue to update me on issues as they arise.