SMTP Smarthost to Office 365 and Gmail

I use the Windows SMTP service to relay some mail to Office 365 and, from another site, to Google Apps Gmail. Here are some notes and links on both.

SMTP General

The default outbound message size limit is 2MB. If you’re sending larger messages, increase that on the Messages tab:

 SMTP Smarthost 1

Set up shortcuts to the SMTP Logs and SMTP folders (including Badmail and Queue):

Logs:  C:\Windows\System32\LogFiles\SMTPSVC1

Badmail and Queue:  C:\inetpub\mailroot

Office 365 Smarthost

There are lots of article on setting this up (example, example). A few key points:

  • There are ways to set up a connector to trust all mail coming from a certain server. Since I’m dealing with servers behind dynamic IP addresses, I did not want to use this approach.
  • The other approach is to authenticate as an Office 365 user (using the user’s email address and password). This does not require any additional configuration in the Office 365 portal. However, this does seem to require that the mail itself come From that user, i.e. if your Office 365 account is [email protected], your device (printer, router, UPS, whatever) must send notification emails from that same [email protected] address.
  • Mail must be sent to smtp.office365.com using TLS on port 587.
  • See also my article last year on SMTP service certificates.

Google Apps Gmail Smarthost

Google Apps does require some configuration in the portal to allow relaying. This is described in their article SMTP relay service setting.

Google is a little more flexible:  you can make TLS optional (I set it as required) and it may work on other ports (I stuck with 587). You still set up the SMTP service to authenticate as a Gmail user, but it does seem to allow for the email to come From another valid user in the domain. In other words, I set authentication in the SMTP service to connect as [email protected], but mail from the Linux server is coming From [email protected]

The Google server is smtp-relay.gmail.com.

Sending from Linux

Mail from the Linux “root” user will by default be sent From [email protected], which Google (and probably Office 365) would reject.

So how do you get the Linux box to send as a known user in your email domain, e.g. [email protected]? I got that to work by setting up smarthost, domain masquerading, and “address rewriting” using generics, telling it that mail from “root” was actually from [email protected]. This article describes editing the sendmail.mc file. I edited sendmail.mc manually, then used Webmin to get it to rebuild the Sendmail M4 Configuration. Webmin also let me set up the Outgoing Addresses and Aliases.

 

SMTP Smarthost 2

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.