Question

Postfix: SASL authentication failed (Ubuntu 14.04 / Office365)

I’m unable to get postfix to work with our office 365 mail.

here’s the main.cf file:

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

append_dot_mydomain = no

readme_directory = no

smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache


smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = signa-01
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = signa.com, signa-01, localhost.localdomain, localhost
relayhost = [smtp.office365.com]:587
mynetworks = 127.0.0.0/
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all
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
smtp_sasl_mechanism_filter = login

And here is the error from mail.log:

Jul 15 04:50:28 signa-01 postfix/smtp[29736]: 211B2184D2E: SASL authentication failed; server smtp.office365.com[132.245.73.194] said: 535 5.7.3 Authentication unsuccessful
Jul 15 04:50:28 signa-01 postfix/smtp[29736]: connect to smtp.office365.com[2a01:111:f400:5387::2]:587: Network is unreachable
Jul 15 04:50:28 signa-01 postfix/smtp[29736]: 211B2184D2E: to=<clgsplace@gmail.com>, relay=none, delay=13, delays=0.02/0.02/13/0, dsn=4.4.1, status=deferred (connect to smtp.office365.com[2a01:111:f400:5387::2]:587: Network is unreachable)

Things I’ve done:

  • I used this tutorial to configure postfix with 365
  • I’ve verified the username and password are correct in /sasl_passwd
  • I’ve tried adding smtp_sasl_mechanism_filter = login to main.cf

How can I troubleshoot this?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi!

Per the error log:

Jul 15 04:50:28 signa-01 postfix/smtp[29736]: connect to smtp.office365.com[2a01:111:f400:5387::2]:587: Network is unreachable

It looks like Postfix is not able to connect to Office356’s SMTP relays. By default, Postfix tries to use either IPv6 or IPv4 in that order. However, SMTP traffic is blocked on our IPv6 addresses as to prevent abuse because Droplets currently receive /16 blocks instead of the more commonly used /64 size.

In order to configure Postfix to make and accept connections over IPv4 only, add the following line to main.cf:

inet_protocols = ipv4

and restart Postfix:

sudo service postfix restart

Let me know how that goes!