Sendmail Configuration postfix Install with Gmail SMTP

Sendmail Configuration postfix Install with Gmail SMTP

If You’r are running a Linux server and accept email, the only Sendmail Configuration is to use your mail service’s (SMTP) Simple Mail Transfer Protocol server.

Sendmail Configuration Google’s Gmail features a vigorous SMTP server that you simply can effectively arrange a Linux mail exchange specialist (MTA) like Sendmail or Postfix to utilize.

Prerequisites

  1. Need root access
  2. Gmail Account with “Less secure app access” enable.

Sendmail Configuration Action Plan:

Step 1:

Update the Package (optional)

sudo yum update

Step 2:

Install the mailx and postfix

sudo yum install postfix -y
yum install mailx -y

Step 3:

Check the install mailx and postfix with version

rpm -qa | grep postfix

rpm -qa | grep mailx

Check the install mailx and porstflix

Step 4:

change the directory ‘/etc/postfix/’ in the directory we see main.cf and make a backup the file 

cp main.cf main.cf_backup

backup the file 

Step 5:

After the backup now we configure the main.cf Add the two below two lines to the respective location. for the hostname use 

relayhost = [smtp.gmail.com]:587

respective location. for the hostname use 

myhostname= <your_hostname>

respective location. for the hostname use 1

And add these lines in the last of the file main.cf

####################################################

# Location of sasl_passwd we saved

smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd

# Enables SASL authentication for postfix

smtp_sasl_auth_enable = yes

smtp_tls_security_level = encrypt

# Disallow methods that allow anonymous authentication

smtp_sasl_security_options = noanonymous

the last of the file main.cf

Step 6:

Create a directory ‘sals’ under ‘/etc/postfix/sasl/’

mkdir /etc/postfix/sasl/

Create a fie ‘sasl_passwd’under /etc/postfix/sasl/sasl_passwd

touch /etc/postfix/sasl/sasl_passwd

Step 7:

Generate an app password to use with Gmail’s SMTP server

 

sign in to the google account below link

https://myaccount.google.com/intro/security

Go to the Security and scroll down enabled two-factor authentication.

Go to the Security

in the search 🔎 box Search for the ‘app passwords’ and select it

'app passwords'

Enter the app name EX: SMTP click on Create button 

click on Create button

Notice the 16 digits password and copy the password

Notice the 16 digits password and copy the password

Step 8:

Add the below line In the file /etc/postfix/sasl/sasl_passwd relace your mail and password.

[smtp.gmail.com]:587 your_mail@gmail.com:generated_password

mail and password.

Step 9:

Use postmap for database converting we notice below .db extension

postmap /etc/postfix/sasl/sasl_passwd

change the permissions.

chmod 600 *

Use postmap for database converting we notice below .db extension

Step 10:

Now we stop the sendmail if active

systemctl stop sendmail

Now we start the postfix

systemctl start postfix

systemctl enable postfix

systemctl status postfix

Now we start the postfix

Step 11:

Now Testing the sendmail

test mail

The Output of the mail both Gmail and Outlook

gmail output

 

The sendmail install successfully.

Thank you

Leave a Comment