Posts Tagged ‘msmtp’

Easy delivery with mstmp and GMail

Friday, January 23rd, 2009

At the moment, I really don’t feel like setting up a full-fledged MTA such as sendmail, postfix or qmail. I want to take the simple course, basically because I’m lazy. Fortunately, there are a variety of simple SMTP ‘relays’ out there such as ssmtp and esmtp. Some network officianatos may consider this to be re-inventing the wheel, but then again, I’m sure glad that my car doesn’t roll on stone cylinders.

After some consideration, I chose to go with msmtp. I like its flexible configuration, and it’s just the right size for the job (with room to grow). The major thing I was looking for was STARTTLS support. I wasn’t so concerned with the trust files and certificates, I just had a need to support GMail’s minimum requirements. Yes, msmtp gives you that and the whole 9 yards, for when I need them all.

msmtp Configuration for GMail

With a combination of their official configuration example plus a few targeted suggestions from Grey Bearded Geek’s take at ssmtp, I came up with the following:

You plop in the GMAIL-USER and GMAIL-PASSWD, and you’re good to go.

Custom From: Address

I soon learned that the from and maildomain settings are irrelevant; Google will not arbitrarily change the From: header of your mail. That makes sense. So the mail will appear as if it’s coming from you, personally. Well, it turns out that there’s a few things you can do to get around that.

  • Create yourself a dedicated GMail account. Now you have isolated your soon-to-be-wildly-popular start-up’s e-mail account from your personal one.
  • Follow the instructions on adding a custom From: address to your account. I had to use the older version of the GMail interface to do so. Google will verify that you own the address — you’d better be able to receive mail at that address — and then you can make it your default.

    GMail will now send your mail as it were coming from that address, but it will do so without providing an alias.

  • When sending your outbound mail, you can include the following headers:
    From:  ALIAS 
    Reply-To:  ALIAS <USER@DOMAIN>

    Google will respect the ALIAS portion of the From: address, though not the address itself. The Reply-To: is optional, but respected in its entirety (alias and address).

Works like a charm.