Projects‎ > ‎Arduino Yun‎ > ‎

Send email with ssmtp on OpenWRT

Send Email with Ssmtp on OpenWrt

SSMTP is a program to deliver an email from a local computer to a configured mailhost (mailhub). 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 Openwrt you can use command or text email’s draft to send email from OpenWrt

Requirements

OpenWrt’s minimum size requirements = (1.99 MB)

Installation and Configuration

Step 1: Install SSMTP

  1. Open OpenWrt’s LuCI Web’s Interface
  2. Select Tabs System – Software
  3. Click Update List
  4. In download and install packages type “ssmtp” then click ok

Step 2: Configure SSMTP

  1. cd /etc/ssmtp
  2. vi ssmtp.conf

Edit ssmtp.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#
 
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=username@gmail.com
 
# The place where the mail goes. The actual machine name is required
# The example will fit if you are in domain.com and your mailhub is so named.
mailhub=smtp.gmail.com:587
 
# Where will the mail seem to come from?
#rewriteDomain=
 
# The full hostname
hostname=username@gmail.com
UseSTARTTLS=YES
AuthUser=username@gmail.com
AuthPass=password_on_gmail
 
# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
FromLineOverride=YES
 
# Use SSL/TLS to send secure messages to server.
UseTLS=YES
 
# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES
 
# Use this RSA certificate.
#TLSCert=/etc/ssl/certs/ssmtp.pem
 
# Get enhanced (*really* enhanced) debugging information in the logs
#Debug=YES

Testing

To test if SSMTP is working properly:

– From email’s draft

Create test email.txt on /tmp folder

1
2
cd /tmp
vi test email.txt
Edit test email.txt using the proper formatting of SSMTP
1
2
3
4
5
To: destination.address@gmail.com
From: your.email@gmail.com
Subject: This is a test mail
 
Body of email..
Send email to destination.address using test mail.txt email’s draft
1
ssmtp destination.address@gmail.com < test mail.txt

Troubleshooting

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

1
Debug=YES