Sending Emails

Oct 19, 2016

There are a number of packages for LEDE/OpenWRT that allow you to send emails. We are going to be looking at SSMTP.

With email sending configured, you could set up automatic emails such as system alerts, or to goof around with sending emails via CLI.

Here we will run you through the steps needed to get the packages installed and basic usage.

SSH to your OpenWRT device

If you are using Windows then start PuTTY and click Session on the left side, select SSH from the options, and then enter in the IP Address of your OpenWRT box into the Host Name field.

Once you’ve done this just click on Open to start up the SSH connection.

If you are connecting via terminal, then just SSH to your OpenWRT device using the following command, where 192.168.1.1 is your OpenWRT device’s IP address.

Installation

Installing SSMTP is quick and easy. Just run the following commands:

opkg update
opkg install ssmtp

Configuration

Next we need to edit the SSMTP config file with your mail server details, run the following command:

vi /etc/ssmtp/ssmtp.conf

You should see something similar to the following:

# /etc/ssmtp/ssmtp.conf
[email protected]

mailhub=smtp.gmail.com:587
rewriteDomain=gmail.com
[email protected]

UseTLS=Yes
UseSTARTTLS=Yes

[email protected]
AuthPass=password

FromLineOverride=yes

Fill in with your mail server details. For more information, search for your email provider’s SMTP settings.

Sending Emails

There are a few ways to send emails using SSMTP. The simplest is to create a text file and run a command to send it.

First create a text file by running the following:

vi /tmp/email.txt

Now populate your text file using the following format:

To:[email protected]
From:[email protected]
Subject: Test

This is the body of the email

Once you have written your email you can send it using the following command:

mail [email protected] < email.txt

For more information on the other methods, and what else you can do with SSMTP, take a look at this wiki page.


CT WiFi is a cloud based WiFi management platform for businesses. The firmware gives consumer-grade WiFi access points enterprise-like capabilities. Or you can utilise the captive portal solution with your existing infrastructure. Create a free account and check it here ct-networks.io

Come join CT WiFi

Sign Up

Sign-up for CT WiFi, it's free for unlimited access points :)