Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm decommissioning an Exchange server and moving the mail accounts to Office365. However, some of the computers on my LAN generate email status messages. Previously those were delivered to my in-house Exchange server by postfix. Now I'd like to relay them to the Office365 servers.

I have postfix running on a linux box that also serves as my firewall and router. All of the clients generating status emails connect to the firewall box. The firewall box generates email status messages as well, too.

From reading on the web I think my problem is configuring postfix so that it will relay all local mail, which apparently by default it doesn't do.

I know this is possible because I configured postfix on a Raspberry Pi attached to the LAN and was able to get emails generated on the Pi relayed out to the Office365 servers. It's more than a little maddening that I can't duplicate that functionality on the firewall/router :). Even using the Pi's postfix configuration files.

Here's the relevant part of main.cf:

# TLS parameters
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = wiggle_butt
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
relayhost = smtp.office365.com:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtp_tls_security_level = may
smtp_generic_maps = hash:/etc/postfix/generic
#transport_maps = hash:/etc/postfix/transport
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

The hosts file looks like this: localhost wiggle_butt.arcabama.com wiggle_butt

And resolv.conf:


The error message I'm getting looks like this:

Jul 25 07:34:04 wiggle_butt postfix/smtp[5004]: C1C446F8002: 
to=<mark@arcabama.com>, relay=none, delay=0.06, delays=0.05/0.01/0/0, 
dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for 
name=arcabama-com.mail.protection.outlook.com type=MX: Host not found, try again)


postconf -n output...

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/lib/postfix
data_directory = /var/lib/postfix
html_directory = /usr/share/doc/postfix-2.10.0/html
inet_interfaces = all
inet_protocols = ipv4
mail_owner = postfix
mailbox_size_limit = 0
mailq_path = /usr/bin/mailq
manpage_directory = /usr/share/man
mydestination =
myhostname = wiggle_butt.arcabama.com
mynetworks = [::ffff:]/104 [::1]/128
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.0/readme
recipient_delimiter = +
relay_domains = arcabama.com
relayhost = smtp.office365.com:587
sample_directory = /etc/postfix
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
smtp_generic_maps = hash:/etc/postfix/generic
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_tls_cert_file = /etc/postfix/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/postfix/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
share|improve this question
If you're sending mail for domains that aren't "public", try setting up a transport table for the domain, using relay:[server.fqdn.com], the [] means no MX lookup. –  NickW Jul 25 '13 at 15:09
Could you show output of the # postconf -n –  ALex_hha Jul 25 '13 at 15:11
Alex_hha: added postconf -n output to question. –  DiegoGarcia Jul 25 '13 at 16:18
NickW: your comment got me thinking about what would happen if I specified the precise Microsoft email host. So I tried setting relayhost = [exact host]:587. It failed with a similar name not found/A record kind of problem. Which leads me to think this has something to do with DNS, or postfix's use of DNS, on my system. Yet nslookup and dig successfully resolve all sorts of names, including smtp.office365.com. –  DiegoGarcia Jul 25 '13 at 16:20
NickW: BTW, I did try setting up a transport db, with the following entry: *.arcabama.com smtp:smtp.office365.com Mail delivery still failed with the same error message. –  DiegoGarcia Jul 25 '13 at 16:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.