- Consulting
- Training
- Partners
- About Us
x
Have you ever thought of setting up a web or application server with your own mail server? Have you ever tried to do so and stuck at some point? Well, when you host a website or your application it is likely to have your own mail server to handle incoming and outgoing mail to your domain. Before I get into my topic, I assume that you have got basic knowledge on AWS. For any kind of cloud training please visit www.cloudthat.com. Here, I’m going to explain you how to setup a simple postfix email server with AWS SES to handle all your email needs of the application. AWS SES (Simple Email service) is a cost effective email service built on AWS cloud. You will be launching an Amazon EC2 machine to setup your email server. Let me put it in this way. We have got two phases in this implementation.
Domain name is essentially the name given to your website, which helps the visitors to remember the site. For example, we have got a domain cloudthat.com and we have the websites like blog.cloudthat.com, training.cloudthat.com with different purpose. Lets come to the Email part. Email address will be always with a domain name. In order to send a mail through SES we have to verify our domain name so that we can use any Email ID with this domain name as from address. Let’s verify our domain name with SES.
Note: This will create an IAM user for you with needed SES privileges.
In this phase you are going to launch an EC2 machine. Then you will install postfix as your mail transfer agent (MTA) and configure your postfix to talk to SES which we configured now. Let’s go step by step to configure the mail server.
Now let’s login to our machine using putty or any SSH client. First, make sure to set the hostname.
1 2 |
$vim /etc/hosts 127.0.0.1 mail.yourdomain.com |
1 2 3 4 |
$vim /etc/sysconfig/network # ... HOSTNAME=mail.yourdomain.com # ... |
We will install postfix as our MTA to send and receive mail.
1 |
$ sudo yum install postfix |
We need to make minimum changes in postfix configuration to enable our mailing service. Let’s do it one by one.
1 2 3 4 5 6 |
$vim /etc/postfix/main.cf mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain mydomain = yourdomain.commy hostname = mail.yourdomain.com mynetworks_style = host myorigin = $mydomain |
To integrate our postfix to SES we need to add few more lines to main.cf file.
1 2 3 4 |
relayhost = [email-smtp.us-west-2.amazonaws.com]:25smtp_sasl_auth_enable = yes smtp_sasl_security_options = noanonymoussmtp_sasl_password_maps = hash:/etc/postfix/sasl_passwdsmtp_use_tls = yes smtp_tls_security_level = encrypt smtp_tls_note_starttls_offer = yes |
Note:Relay host will change depend upon the SES region you use. To get the SES end point visit Regions and Endpoints.
Comment out the following line of the master.cf file by putting a # in front of it:
1 2 |
$vim /etc/postfix/master.cf #-o smtp_fallback_relay= |
Edit the /etc/postfix/sasl_passwd File. Create the file if it does not exist
1 2 3 |
$vim /etc/postfix/sasl_passwd [email-smtp.us-west-2.amazonaws.com]:25 USERNAME:PASSWORD |
Note: Add your SMTP username and password which you downloaded. Save and close the file use the following command to create a hashmap database file containing your SMTP credentials.
1 |
$sudo postmap hash:/etc/postfix/sasl_passwd |
Now we have to tell postfix where to find CA certificates. This is very much needed to verify the Amazon SES server certificates.
1 |
$sudo postconf -e 'smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt' |
Stop and start postfix
1 2 |
$sudo postfix stop $sudo postfix start |
We are ready with your mail server. Lets send a test email.
1 2 3 4 5 |
sendmail -f from@yourdomain.comto@example.com From: from@yourdomain.com Subject: Test Email This email was sent through Amazon SES! . |
Note: you must replace from@example.com with your “From” email address, which you must have previously verified with Amazon SES. Replace to@example.com with your “To” address. If your account is still in the sandbox, the “To” address must also be verified.
Voiced by Amazon Polly |
CloudThat is a leading provider of cloud training and consulting services, empowering individuals and organizations to leverage the full potential of cloud computing. With a commitment to delivering cutting-edge expertise, CloudThat equips professionals with the skills needed to thrive in the digital era.
Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!
Arundhati
Jul 8, 2016
V. Informative & usefull
Click to Comment