SSL on Post fix

 
I have given a task to relay post fix mail with g mail. I have post fix installed and working on y local system and delivering mail to my local user test1 and test2.

Following is log for mail delivery .



Feb 21 15:16:06 localhost postfix/smtpd[3149]: 102C4C42F9C: client=localhost[::1]
Feb 21 15:16:23 localhost postfix/cleanup[3153]: 102C4C42F9C: message-id=<20190221094606.102C4C42F9C@mail.example.com>
Feb 21 15:16:23 localhost postfix/qmgr[3141]: 102C4C42F9C: from=<test1@example.com>, size=305, nrcpt=1 (queue active)
Feb 21 15:16:23 localhost postfix/local[3154]: 102C4C42F9C: to=<test2@example.com>, orig_to=<test2>, relay=local, delay=24, delays=24/0.02/0/0.02, dsn=2.0.0, status=sent (delivered to maildir)
Feb 21 15:16:23 localhost postfix/qmgr[3141]: 102C4C42F9C: removed

Step:Now i am going to use gmail id as relay.

For this first i create:tls policy file

#vim /etc/postfix/tls_policy
following entry in the file:

[smtp.gmail.com]:587 encrypt

Step:then create sasl_posswd file./etc/postfix/sasl_passwd

#vim /etc/postfix/sasl_passwd
following entry in this file
[smtp.gmail.com]:587 qayoom2009@gmail.com:xxxxxxx(password)


step:Then add db of above file with postmap:
#postmap hash:/etc/postfix/tls_policy
#postmap hash:/etc/postfix/sasl_passwd

Step:then make following at ent of the /etc/postfix/main.cf

smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
#smtp_sasl_security_options = noanonymous, noplaintext
smtp_tls_CApath = /etc/ssl/certs
smtp_use_tls = yes
#debug_peer_level=3


  also make relay gmail as

relayhost = [smtp.gmail.com]:587




step:Then restart the postfix.

Make my g mail less secure. In google account security.




 
Step:Also two way verification turn off.







Step:Test mail with telnet as below.face lot of issue in this step trouble shoot and avoid relayhost error.then following error is coming .

Error







Mail defered as in log:

[root@mail ~]# grep DE0E2C42F9C /var/log/maillog
Feb 21 16:34:04 localhost postfix/smtpd[3868]: DE0E2C42F9C: client=localhost[127.0.0.1]
Feb 21 16:34:15 localhost postfix/cleanup[3871]: DE0E2C42F9C: message-id=<20190221110404.DE0E2C42F9C@mail.example.com>
Feb 21 16:34:15 localhost postfix/qmgr[3866]: DE0E2C42F9C: from=<test2@example.com>, size=318, nrcpt=1 (queue active)
Feb 21 16:34:20 localhost postfix/smtp[3872]: DE0E2C42F9C: SASL authentication failed; cannot authenticate to server smtp.gmail.com[74.125.24.109]: no mechanism available
Feb 21 16:34:25 localhost postfix/smtp[3872]: DE0E2C42F9C: to=<qayoom2009@gmail.com>, relay=smtp.gmail.com[74.125.24.108]:587, delay=41, delays=31/0.03/9.4/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.gmail.com[74.125.24.108]: no mechanism available)

after lot of R&D i found following commnad:

Solution


step:#yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain
its work and issue resolved. Now i can send mail to any one by using my google id.

Success log:
Feb 21 16:43:03 localhost postfix/smtpd[4030]: AB329C42F9C: client=localhost[127.0.0.1]
Feb 21 16:43:14 localhost postfix/cleanup[4032]: AB329C42F9C: message-id=<20190221111303.AB329C42F9C@mail.example.com>
Feb 21 16:43:14 localhost postfix/qmgr[4025]: AB329C42F9C: from=<test2@example.com>, size=318, nrcpt=1 (queue active)
Feb 21 16:43:18 localhost postfix/smtp[4027]: AB329C42F9C: to=<qayoom2009@gmail.com>, relay=smtp.gmail.com[74.125.68.109]:587, delay=29, delays=26/0/2.1/1.1, dsn=2.0.0, status=sent (250 2.0.0 OK 1550747598 u13sm33812937pfa.169 - gsmtp)
Feb 21 16:43:18 localhost postfix/qmgr[4025]: AB329C42F9C: removed



Comments

Popular posts from this blog

Docker Private Registery