Configure Postfix SMTP relay office365 on OEL 6 & 7
https://www.onceuponanipsum.com/relay-mail-with-office-365-and-postfix/
Install Postfix using command below
[root@localhost ~]# yum install postfix cyrus-sasl-plain mailx
1. vi /etc/postfix/main.cf
relayhost = [smtp.office365.com]:587
mynetworks = 127.0.0.0/8
inet_interfaces = loopback-only
smtp_use_tls = yes
smtp_always_send_ehlo = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_security_level = encrypt
smtp_generic_maps = hash:/etc/postfix/generic
#smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
2. vi /etc/postfix/sasl_passwd
[smtp.office365.com]:587 o365test@expolanka.com:P@ssw0rd
3. postmap /etc/postfix/sasl_passwd
4. chown root:postfix /etc/postfix/sasl_passwd
5. chmod 640 /etc/postfix/sasl_passwd
6. vi /etc/postfix/generic
root@edbtest.expolanka.com o365test@expolanka.com
7. chown root:root /etc/postfix/generic
8. chmod 0600 /etc/postfix/generic
9. postmap /etc/postfix/generic
10. vi /etc/aliases
mailer-daemon: postmaster
postmaster: root
root: o365test@expolanka.com
11. [root@localhost ~]# newaliases
12. service postfix restart
13. echo "this is a test gmail" | mail -s "test message gmail" prmdth@gmail.com
echo "this is a test o365" | mail -s "test message o365" o365test@expolanka.com
echo "This is the body of the email"| mail -r"o365 mail<o365test@expolanka.com>" -s "This is the subject(E-Mail from SMTP Relay) line" pramudithad@itx360.com
14. Troubleshoot
tail -f /var/log/maillog
No comments:
Post a Comment