Setting up a minimal mail server with Exim 4
Q I'm trying to set up a remote host so that I can send logs via Mail, Mailx or Mutt using Cron jobs on, say, a weekly or monthly basis. Setting up the Cron jobs isn't an issue, it's the mail setup that I need help with. Currently, I have installed Exim4 on Ubuntu 9.04, but I require the configuration side so I can send mail via my ISP. Any help would be great, because all the docs I have read are conflicting. All I want to do is send emails from a script command or shell.
A You don't need to use a full-blown mail transfer agent if all you want to do is relay mails through your ISP's mail server. There are a couple of minimal mail relays designed to do just this. They don't handle local delivery or receive mail from other servers - all they do is pass your mail on to a proper mail server, such as the one provided by your ISP.
Each of these relay agents has its own set of advantages and drawbacks. First up is SSMTP, which doesn't appear to be under active development right now. Its other disadvantage is that it doesn't handle failure well - it can report success when the mail wasn't really sent. On the other hand, it supports sending over SSL/TLS encrypted connections, which can be important if you're using a wireless laptop and don't want anyone sniffing out your mail login and password. Nullmailer performs a similar task, is still in development and provides better information about the result of a mail attempt, but it doesn't support encrypted connections. Each program provides a Sendmail replacement, and Mullmailer also runs a mailer daemon. Both are available in the Jaunty repositories to be installed via Synaptic.
To use SSMTP, just edit the /etc/ssmtp/ssmtp.conf file. There are only two settings you really need; Mailhub should be set to the address of your ISP's mail server and Root should be set to an address to receive mail addressed to the root user (the kind of mail sent by Cron tasks, for example). If your ISP's server uses a port other than 25, add this to the Mailhub setting, for instance:
Nullmailer uses several files in /etc/nullmailer, each containing one setting. These are as follows:
1. Adminaddr - Contains the address that root mails are received at.
2. Defaultdomain - Contains a domain that's added to addresses only containing a host.
3. Me - The fully qualified host name of the computer running Nullmailer.
4. Remotes - Contains one or more servers used to send the mail.
The format of the remotes file is:
address protocol options
The address can be a domain or IP address, the protocol is almost always SMTP and the options can be used to set a different port or add user authentication. All of these are valid:
mail.example.com smtp --port 465
mail.example.com smtp --user=michael --pass=peekaboo
With Nullmailer you also need to set the service to run at boot. Now you can use Mailx or Mutt to your heart's content and let your ISP take care of delivering the mails.
Follow us on Identi.ca or Twitter