Sunday, 26 November 2023
Oracle Apps R12: How To Renew SSL Certificate on Apps Tier in 5 minutes
Wednesday, 22 November 2023
How to configure Postfix SMTP relay office365 on Centos
Postfix:
Postfix is a flexible mail server
that is available on most Linux distribution. Though a full featured mail
server, Postfix can also be used as a simple relay host to another mail server,
or smart host. This tutorial will describe how to configure Postfix as a relay
through Office365.
Requirement:
CentOS or Red Hat Enterprise
Linux
Valid Office365 email credentials.
Installation:
Install Postfix using
command below
[root@localhost ~]# yum install postfix
cyrus-sasl-plain mailx
Configuration changes:
Postfix main configuration file
is main.cf, let's make the required change as follow:
[root@localhost ~]# vi /etc/postfix/main.cf
Append the following line
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
sender_canonical_classes = envelope_sender, header_sender
sender_canonical_maps = regexp:/etc/postfix/sender_canonical_maps
smtp_header_checks = regexp:/etc/postfix/header_check
Rewrite envelope address from email originating from the server itself
/etc/postfix/sender_canonical_maps:
/.+/ newsender@address.com
Rewrite from address in SMTP relayed e-mail
/etc/postfix/header_check:
/From:.*/ REPLACE From: newsender@address.com
Save and exit from the file.
The configuration of
postfix SASL credentials:
[root@localhost ~]# vi /etc/postfix/sasl_passwd
Add a line below
[smtp.office365.com]:587 user@domainname:password
Save and exit from file
A Postfix lookup table must now
be generated from the sasl_passwd text file by running the following command.
[root@localhost ~]# postmap
/etc/postfix/sasl_passwd
Now change permission for this
file
[root@localhost ~]# chown root:postfix
/etc/postfix/sasl_passwd
[root@localhost ~]# chmod 640
/etc/postfix/sasl_passwd
Next let's correct the
file permission.
[root@localhost ~]# chown root:root
/etc/postfix/generic
[root@localhost ~]# chmod 0600 /etc/postfix/generic
[root@localhost ~]# postmap /etc/postfix/generic
/etc/postfix/main.cf:
Let's restart Postfix
service.
[root@localhost ~]# systemctl restart postfix
Now try to send a test
email using the command below:
FOR
Centos:
echo "This is the body of the email"|
mail -r"Sender-Display-Name<sender@domain.com>" -s "This is the subject(E-Mail from
SMTP Relay) line" recipeat@gmail.com