Ken (Chanoch) Bloom's Blog

15th July 2007

Masqmail

I had been looking to configure an email server that

  1. accepted SMTP connections on localhost:25,
  2. accepted mails through /usr/bin/sendmail
  3. would use smtp.gmail.com's TLS interface as a smarthost.
  4. wasn't difficult to configure, since I don't actually care about local delivery.

All of the standard choices for the first 3 requirements including Exim, and Postfix are IMO difficult to configure because you also have lots of options for how to configure local delivery.

So I found masqmail, which handles 1,2 and 4 admirably, and would do just fine with 3, if it didn't have to use TLS (since masqmail doesn't support TLS). After exploring around for a while, I found that Masqmail has two options for delivery to a smarthost:

  1. send directly to an SMTP server
  2. pipe the message to an external program

So I began looking at an external program to use.

My previous configuration mail configuration had been to use ssmtp as my MTA, but that only supported requrements 2,3 and 4. My first expermient was to use ssmtp as the masqmail's external program. To use ssmtp for this purpose, I had to compile it from scratch for Debian since all of the sendmail providers conflict with each other. (No /etc/alternatives support for the MTA)

I discovered in Debian's archives a similar program, esmtp. The maintainers of esmtp were smart enough to split the sendmail functionality from the rest of the package, creating the esmtp package with the mailer, and the esmtp-run package with the sendmail symlink.

So I installed esmtp (but not esmtp-run which provides the sendmail symlink) and set up masqmail as follows: in /etc/masqmail/masqmail.conf (among other options):

online_detect=pipe
online_pipe="/bin/echo gmail" #arguably I should do something smarter here
online_routes.gmail="/etc/masqmail/gmail.route"

in /etc/masqmail/gmail.route:

protocol="pipe"
pipe="/usr/sbin/esmtp ${rcpt}"

in /etc/esmtprc:

hostname=smtp.gmail.com:587
username=myusername@gmail.com
password=FatChanceOfMeTellingYou
starttls=required

Update Dec 30, 2008: Matan Ziv-Av pointed out to me that "when a message has multiple recipients, masqmail tries to deliver to each one, but esmtp -t sends to all recipient, according to the message's headers, so every recipient gets as much messages as there are recipients." I have updated /etc/masqmail/gmail.route to use esmtp ${rcpt}.

Permalink | linux.
My Website Archives

Tags