I run a remote Raspberry PI gracefully hosted by the people over at raspberrycolocatie.nl Since one if it’s jobs is to run a few scripts monitoring various bits and pieces I want it to be able to send emails. Since I don’t want to use a full blown MTA I settled for ssmtp.
It’s worth noting that this setup applies to any debian box, not only the rPI.
sSMTP - Simple SMTP
sSMTP is a simple MTA to deliver mail from a computer to a mail hub (SMTP server). sSMTP is simple and lightweight, there are no daemons or anything hogging up CPU; Just sSMTP. Unlike Exim4, sSMTP does not receive mail, expand aliases, or manage a queue.
Here are the few, simple steps needed to get it up and running:
Install ssmtp using apt-get (sudo or run it as root)
sudo apt-get install ssmtp Reading package lists... Done Building dependency tree Reading state information... Done (...snip...) Setting up libgnutls-openssl27:armhf (2.12.20-7) ... Setting up ssmtp (2.64-7) ...
Configure ssmtp to use an email account. Note that ssmtp sends mail as a client to a remote mail server (i.e. gmail) not as a traditional MTA. Be sure to adjust ports and TLS settings according to your setup.
/etc/ssmtp/ssmtp.conf to look like below:
# # Config file for sSMTP sendmail # # The person who gets all mail for userids < 1000 # Make this empty to disable rewriting. firstname.lastname@example.org # The place where the mail goes. The actual machine name is required no # MX records are consulted. Commonly mailhosts are named mail.domain.com mailhub=mail.example.com:587 # Where will the mail seem to come from? #rewriteDomain= # The full hostname email@example.com UseTLS=YES UseSTARTTLS=YES AuthUserfirstname.lastname@example.org AuthPass=secretPassword # Are users allowed to set their own From: address? # YES - Allow the user to specify their own From: address # NO - Use the system generated From: address FromLineOverride=YES
# sSMTP aliases # # Format: local_account:outgoing_address:mailhub # # Example: root:email@example.com:mailhub.your.domain[:port] # where [:port] is an optional port number that defaults to 25. root:firstname.lastname@example.org:mail.example.com:587
Install mailx and test sending.
apt-get install mailutils (... snip ...) Setting up mailutils (1:2.99.97-3) ...
mailx email@example.com Cc: Subject: Test Message Enter some text here End with CTRL+D to send