SUSE Linux Enterprise Server 15
SUSE Linux Enterprise Server 12 SP3 and higher
SUSE Linux Enterprise Server 11 SP4
I need to configure Postfix to relay my mail to Office365, how can I do this ?
Assumptions: You have a valid Office365 account e-mail address and password. You are not using "Postfix masquerading". It is also assumed you have a working Postfix configuration and that it can send out mail without a problem.
1. On SLES11, SLES12, or SLES15 have postfix installed and if it is running, shut it down with:
rcpostfix stop
or
systemctl stop postfix
2. On your postfix SLES box cd to /etc/postfix directory as the "root" user in a terminal.
3. Unless you have this file in place already, touch a file called "sasl_passwd", but does not matter the name though, i.e.:
touch sasl_passwd
4. Edit the file and place this content in it :
[smtp.office365.com]:587 <office365AccountEmailAddress>:office365AccountPassword>
5. Put a blank line at the end of the file
6. Save the file
7. Now compile the /etc/postfix/sasl_passwd file with :
postmap hash:/etc/postfix/sasl_passwd
This will update or create a file called /etc/postfix/sasl_passwd.db, that Postfix will read to know where to attempt to contact office365 with the listed credentials.
NOTE: With SLES 15 SP3, the postfix package has been updated to 3.5.9. Support for "hash" file type has been dropped and a new type of "lmdb" is recommended. Note that this begins with lowercase L. If that is used, the file created above will be named sasl_passwd.lmdb. This information is provided "as is" and has not been specifically tested by the author.
8. In your /etc/postfix/main.cf put these lines in the file unless already there:
Note: Once you copy the below into your main.cf, make sure you do not have any duplicates of any of these lines
in your file :
############################################################
# Minimum Requirements to get Postfix relay to Office365 to work
# sasl and tls
############################################################
relayhost = [smtp.office365.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_tls_security_options = noanonymous
smtp_use_tls = yes
NOTE: Change the above file's reference of hash to lmdb if lmdb was used in step #7.
9. Save the main.cf changes
10. Make sure you have this in your /etc/postfix/master.cf :
tlsmgr unix - - n 1000? 1 tlsmgr
11. Restart postfix with:
rcpostfix restart
or
systemctl restart postfix
12. Test with sending a test message to verify this works as it did for me, with :
mail -s "This is a test message using Postfix with Office365 relay host" -r <office365AccountEmailAddress> <recipientEmailAddress> < /dev/null
Note: You MUST use the "-r <office365AccountEmailAddress> switch as listed above or it will not work
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.