sendmail (simply)

It's important to know when cron jobs fail. One way to do this is to put an entry in the crontab like But for this to work, the system needs a sendmail agent. A rather simplistic option is ssmtp; this is a good option for a system that only needs to send outgoing mail and since it won't receive mail it won't need the overhead of a full MTA.

sudo apt-get install ssmtp  

After installing, the next step is to edit the config file. Check out man ssmtp.conf for more information, but here's a brief example

# most MTAs require authentication and TLS.
# ISPs tend to block port 25 now-a-days.
# SSMTP has us covered!  

If a password is stored in that file, it's important to modify the permissions.

chmod 640 /etc/ssmtp/ssmtp.conf  
chgrp mail /etc/ssmtp/ssmtp.conf  

If users need to sendmail, they can be added to the 'mail' group. Just remember that members of the mail group will be able to read the stored password; if that's a concern, the arch wiki has a great section which details a much better approach.

Keeping up appearances

We don't want to just receive mail from user@host, so the next stop is the /etc/ssmtp/revaliases file. The file should have an explanation and example in it like:

# sSMTP aliases
# Format:       local_account:outgoing_address:mailhub
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.

The final step is adjusting the full name. Use the chfn command.

chfn "User Name" user  

First create a file called test.eml with the following contents:

Subject: Test  

Testing ssmtp!  

Then run the following command:

sendmail -vt <test.eml