Postfix: SASL authentication failed (Ubuntu 14.04 / Office365)

July 15, 2016 1.6k views
Email Apache Ubuntu

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

here's the file:

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

append_dot_mydomain = no

readme_directory = no

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-01, localhost.localdomain, localhost
relayhost = []:587
mynetworks =
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[] said: 535 5.7.3 Authentication unsuccessful
Jul 15 04:50:28 signa-01 postfix/smtp[29736]: connect to[2a01:111:f400:5387::2]:587: Network is unreachable
Jul 15 04:50:28 signa-01 postfix/smtp[29736]: 211B2184D2E: to=<>, relay=none, delay=13, delays=0.02/0.02/13/0, dsn=4.4.1, status=deferred (connect to[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 smtpsaslmechanism_filter = login to

How can I troubleshoot this?

1 Answer


Per the error log:

Jul 15 04:50:28 signa-01 postfix/smtp[29736]: connect to[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

inet_protocols = ipv4

and restart Postfix:

sudo service postfix restart

Let me know how that goes!

  • Hi ther Kamaln,

    Thanks for the response! I just now found this. I've discovered that this wasn't working because the 365 account details we were using was from a shared mail account. Using a main account fixed this.

Have another answer? Share your knowledge.