SMTP mail server setup in Ubuntu Server

Project-2

·

2 min read

SMTP stands for Simple Mail Transfer Protocol, the procedure behind the email flow on the internet.

  1. Mail and ssmtp package install

  2. Gmail security setting

  3. Do change the configuration in the/etc/ssmtp/ssmtp.conf file

  4. To test whether mail is successfully delivered or not run the below command


  1. Install the Packages.

apt-get update

apt-get install mailutils

apt-get install --reinstall ssmtp

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

https://myaccount.google.com/security - Security - Enable Two factor

  1. Create an app password for accessing the mail server inside the ubuntu

An app password is needed to access Gmail from the ubuntu server and it's different from the Gmail password that we use to access Gmail to send mail.

Go to security setting ->> Two Factor Authentication ->> bottom show in App passwords ->> click on other > give the name and generate a password. Take the snapshot after entering the password in Authpass.

  1. 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.

  1. Add Ports in Security Group 25,465,587

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

Config file for sSMTP sendmail

The person who gets all mail for userids < 1000

Make this empty to disable rewriting.

root=postmaster

SERVER=enteryourmailid.com

The place where the mail goes. The actual machine name is required no

MX records are consulted. Commonly mailhosts are named mail.domain.com

mailhub=smtp.gmail.com:465

AuthUser= enteryourmailid.com

Authpass=zsazcfqzqacbfyxz

UseTLS=YES

UseSTARTLS=Yes

Where will the mail seem to come from?

#rewriteDomain=

rewriteDomain=gmail.com

The full hostname

hostname=IbrahimS

Are users allowed to set their own From: address?

YES - Allow the user to specify their own From: address

NO - Use the system generated From: address

#FromLineOverride=YES


A few things are only configured...

SERVER=enteryourmailid.com

mailhub=smtp.gmail.com:465

AuthUser= enteryourmailid.com

Authpass=zsazcfqzqacbfyxz

UseTLS=YES

UseSTARTLS=Yes

rewriteDomain=gmail.com

To test whether mail is successfully delivered or not run the below command

echo " Successfully configured the Mail alert" | mail -s "Test Email" enteryourmailid.com

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