New Smarthost for Local Mail Needed When Migrating from Exchange to Office 365 or Google Apps

Getting ready to move local Exchange services off the LAN and to the Cloud, but wait… how are any applications on other machines going to send mail when the Exchange server is gone? It’s certainly not going to work trying to get Microsoft or Google to relay our internal mail. We need a new Smarthost on the LAN.

myszaLuckily, we have a Linux Server running Postfix available. Previously, this machine sent its mail through the Exchange server. Assuming your network is numbered 192.168.1.x, in /etc/postfix/ change:


relayhost = myexchangeserver.local
mynetworks = [::ffff:]/104 [::1]/128


#relayhost = myexchangeserver.local (You can also just delete this line)
mynetworks = [::ffff:]/104 [::1]/128

and restart Postfix. What we now have is a mail server that will send mail directly through the internet instead of through our Exchange server. In addition, it will accept mail from any machine on our local network without authentication just as our Exchange server was previously configured to do.

One more thing…
Our Linux Server does not have external DNS. Many mail servers will simply not accept mail from a machine called mylinuxserver.local. Here’s how to fix that.

in /etc/postfix/ add the line

smtp_generic_maps = hash:/etc/postfix/generic

then create the file /etc/postfix/generic and add the alias mappings one per line, for example:


Save the file, then from command line

~# postmap /etc/postfix/generic

then restart Postfix. Postfix will now masquerade for the users you specify.

For Cron Jobs that send mail without specifying the sender, a quick fix is to add the line below to the top of each user’s crontab


If you don’t want the mail from a particular cron job, be sure to direct it’s output to /dev/null

For the next week or so, you might want to check the mail logs for bounces. Also, double check internal spam filters that may be blocking mail it shouldn’t. Hunt down the cause and either fix the app sending the mail or add more aliases in /etc/postfix/generic.