Drupal and msmtp

21 Dec 2008
Posted by luciferous
luciferous's picture

I've been working on a Drupal module to allow me to send mail with msmtp. I call it Mailer, which is a terribly creative name, I know. I'm so clever!

Mailer can be extended to work with any SMTP client, but for now has an interface for msmtp. I use msmtp for transmitting mail to the Google SMTP server.

Mailer works by opening a process with popen, and the writing the email into this handle. The same can be done over the command line like this:

$ msmtp -t -a personal
To: recipient@example.com
Subject: Hello!

Mizu wo nomanai dekudasai.

I think it's CTRL-D to signal the end of the email.

Anyway, if you use Drupal and have msmtp (or other SMTP clients eventually) try Mailer instead of the SMTP module with PHPMailer.

Checkout the source.

git clone git://github.com/luciferous/mailer.git

Copy it into your site's module directory, and enable it via Drupal. All that is required for configuring msmtp in Drupal is the path to the msmtp binary, and readable msmtprc somewhere. I put mine in /var/www/.msmtprc.

I'll post up something later about how to extend Mailer to use other SMTP clients.