Configure postfix to use zoho smtp as relay service.

I had a situation in which i setup a nagios server in order to monitor my server hardware and network equipment. I found nagios core to be good sutable for me. I got to setup notification event mails also. I had one isseu in which i could not use phpmail function as all the mails sent were delivered in my junk box.
Now i decided to use any smtp service so i selected zoho here. Now the challange was to setup postfx to use zoho smtp in order to send nagios notifications .
Here are steps i followed for a successful integration.

$ sudo yum install postfix

$ sudo nano /etc/postfix/sasl_passwd

smtp.zoho.com   [email protected]:password

Now post map this credentials and hash them to postfix

$ sudo postmap hash:/etc/postfix/sasl_passwd
$ sudo chmod 600 /etc/postfix/sasl_passwd

 Now edit main.cf file as bellow

$ sudo vim /etc/postfix/main.cf

relayhost = smtp.zoho.com:465
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_tls_wrappermode = yes
smtp_tls_security_level = encrypt
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/Entrust_Root_Certification_Authority.pem
smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cache
smtp_tls_session_cache_timeout = 3600s
sender_canonical_classes = envelope_sender, header_sender
sender_canonical_maps = regexp:/etc/postfix/sender_canonical
smtp_header_checks = regexp:/etc/postfix/smtp_header_checks

Create /etc/postfix/sender_canonical like this

/.+/ [email protected]

Create /etc/postfix/smtp_header_checks file like this

/From:.*/ REPLACE From: [email protected]


Finally, reload postfix and Done

$ sudo postfix reload

If you wish you can office365 and gmail in same manner but you should take care of the smtp server address, mail id, cname, and most important CA certificate. zoho uses entrust as CA sertificate hence i used the same in my main.cf file if you wants to use google or office 365 you should download respective CA sertificate file place it in proper place and make same entry in main.cf file of postfix.
Enjoy.


Comments

  1. Your blog took to me an entirely significant spot. It is a beneficial and factual article to enhance knowledge. Thanks for sharing an article like this.Smtp Service Provider in India

    ReplyDelete

Post a Comment

Popular posts from this blog

Running web ssh client on port 443 /80 with nginx as reverse proxy

Running cockpit behind nginx reverse proxy with nginx ssl and cockpit non ssl

Setup VOD streaming server with nginx using RTMP on Ubuntu 18.04