How do you configure Postfix on SLES11, SLES12, or SLES15 to relay mail to Office365

This document (7023567) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 11 Service Pack 4 (SLES 11 SP4)
SUSE Linux Enterprise Server 12 Service Pack 3 (SLES 12 SP3)
SUSE Linux Enterprise Server 15

Situation

I need to configure Postfix to relay my mail to Office365, how can I do this ?

Resolution

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"

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. 

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.

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

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"

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

Disclaimer

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.

  • Document ID:7023567
  • Creation Date: 06-Dec-2018
  • Modified Date:03-Mar-2020
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback@suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.


SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center