SSMTP is a program to deliver an email from a local computer to a configured mail host (mail hub). It is not a mail server (like feature-rich mail server) but it is using sendmail and does not receive mail, expand aliases or manage a queue. One of its primary uses is for forwarding automated email (like system alerts) off your machine and to an external email address.

With SSMTP on Raspberry Pi you can use command or text email’s draft to send an email from Raspberry Pi

Install Ssmtp

In order for the Raspberry Pi to send an email from the command line you need to install packages on the Raspberry. You are going to need the following packages

  • Ssmtp
    extremely simple MTA to get mail off the system to a mail hub

To install Ssmtp packages run following commands:

If there are no error at installation you can continue to next step

Configure Ssmtp

To configure Ssmtp you need to edit the configuration at /etc/ssmtp folder and edit ssmtp.conf

On nano edit’s interface at ssmtp.conf file, now edit the ssmtp configuration

The configuration

The configuration below is summarized, some configuration is not showed

Testing

To test if ssmtp working properly, run following command on terminal:

Create text mail on /var/tmp folder

Edit test email.txt using the proper formatting of ssmtp
Send an email to the destination address using text mail.txt email’s draft

Troubleshooting

If Ssmtp doesn’t work properly or can’t send email, you can try uncomment debug from ssmtp.conf then retry to resend the email, you’ll get debugging information when sending email:

References

  1. SSMTP – ArchWiki
  2. Image by Alec Perkins / CC BY 2.0