Deployment of SMTP Mail server on AWS EC2 Instance by using Ubuntu & Automate this task via Crontab for sending an email notification for every 1 min:

Deployment of SMTP Mail server on AWS EC2 Instance by using Ubuntu & Automate this task via Crontab for sending an email notification for every 1 min:

Hello Guys, Let's take a look at the below steps, we can have the Server on the cloud/On-premises as well depending on the customer's requirement.

1) Install mailutils & ssmtp Packages in ubunutu:-

2) Enable 2-Step authentication in Gmail security settings.

3) create an app password for accessing the mail server inside ubuntu:-

Go to security, login to 2-step verification, Enter your Gmail password and you will get the App password option there, click on other and generate a new password and keep it with you, an app password is needed to access Gmail from the ubuntu machine and it should be different from the Gmail password that we use to access Gmail to send mail

4) Go to the Gmail setting of your Gmail account click on forwarding and POP/IMAP, and check the IMAP setting if its default is disabled. click on enable.

5) Change the configuration in /etc/ssmtp/ssmtp.conf file by root user:

-----Need to give your Gmail ID to register.
mailhub=smtp.gmail.com:465 ---- give mail hub details as smtp.gmail.com and add port 465 with it. also, add this port to the security group of your ec2 instance.
if port 465 is not work in your case we can add port 587

-----Need to give your Gmail ID
Authpass=jhwfcffmyhtcxrei ----- Need to give APP Password that you created.
UseTLS=YES---- Append this new line
UseSTARTLS=Yes ----- Append this new line
rewriteDomain=gmail.com ----- set rewrite domain name as gmail.com
hostname=devloper.northamerica-northeast1-a.c.potent-arcade-379712.internal ---- do not change this line remains as it is.

I have kept SERVER, AuthUser & Authpass blank in the below snip - Kindly fill this in as per the instructions given above.

6) Check whether an Email is successfully delivered or not?

Run the below command on EC2 , this will send an email to your Gmail account with the subject and content written in it.

You can add this in crontab as well to automate it and send an email as per the requirement.

Now, the BIG thing will come, How to automate this via CRONTAB to send this message at every 1 minute - Notification can be any of your task as per the customer requirement. Here i have demonstrated for an notification email.

and emails are coming in my Gmail for every 1 minute from AWS EC2 Unbunut machine.

Thanks for visiting and reading my Blog, I hope you find this useful.