Wednesday, July 1, 2009

Lightweight SMTP Relay for Debian


I was looking for an easy to use SMTP relay for internal machines that did not require a full postfix deployment. Basically, I wanted something to run ad-hoc that didn't run full-time, to forward my crontab results to another SMTP server. Googl-Fu came up with about a dozen results and of those, I tested and stuck with esmtp-run. The ease of installation and configuration was handy -- I had it running with about 4 lines of typing.

# apt-get install esmtp-run

Modify the host you want to relay to (don't forget to securely configure your relay to allow the connection) by changing the hostname value in the esmtprc configuration file.

# pico /etc/esmtprc
hostname=mail_relay_ip_or_fqdn:25

If you want to change the behavior of the messages that get sent out to force an alternate "reply-to", append this line to the end

force reverse_path=user@example.com

Now whenever cron jobs complete, the mail will get relayed and show a specific reply-to address that I use for administrative functions. The man pages for esmtprc are pretty concise and include several other options you may or may not need. There is support for various connection methods to get authenticated to your SMTP server so make sure you check out the man page for the configuration file.

# man esmtprc

No comments:

Post a Comment