This page lists SMTP and SMTPS clients available on OpenWRT, that are able to send email to other email servers.
The table below is based on Chaos Calmer (15.05).
|msmtp||1.6.2-1||libopenssl||37785||SSL, smarthost only, sendmail-compatible, SMTP auth|
|msmtp-nossl||1.6.2-1||33503||smarthost only, sendmail-compatible, SMTP auth|
|mailsend||1.17b15-2||libopenssl||36679||SSL, smarthost only, no configuration required, MIME, attachements, IPv6, SMTP auth|
|mailsend-nossl||1.17b15-2||34865||smarthost only, no configuration required, MIME, attachements, IPv6, SMTP auth|
|ssmtp||2.64-1.1||libopenssl||11669||SSL support, smarthost only, SMTP auth|
|mini-sendmail||not present on CC||4726||smarthost only, no configuration required|
|emailrelay||1.9-5||libc libssp libopenssl libstdcpp||316||simple SMTP proxy and store-and-forward message transfer agent (MTA); can be used similar to postfix with mail queue in combination with msmtp and mutt|
“smarthost only” means that the program is only capable to send email through a configured “smarthost”, that is, it cannot directly deliver to the destination SMTP server.
Mailsend is a simple command line program to send mail via SMTP protocol.
Being quite lightweight and not requiring any configuration, mailsend is ideal for sending mails in shell scripts.
Depending on whether you want SSL support or not (actually, the size of libopenssl will probably be the decisive factor), install one of the two versions:
opkg install mailsend
opkg install mailsend-nossl
mailsend -f root@openwrt -t email@example.com -smtp smtp.example.com -sub "My subject" -msg-body /tmp/body
For advanced usage (MIME attachements, authentication, BCC, etc), see:
mailsend -h mailsend -example
msmtp is an SMTP client. In the default mode, it transmits a mail to an SMTP server (for example at a free mail provider) which does the delivery. To use this program with your mail user agent (MUA), create a configuration file with your mail account(s) and tell your MUA to call msmtp instead of /usr/sbin/sendmail.
Since msmtp understands standard sendmail options, it can be used in places where sendmail is expected (e.g. PHP code).
opkg install msmtp
Place your configuration in
/etc/msmtprc. There is an existing
default-block in the included config file so if you want to call
msmtp without specifying an account, then you need to rename the existing
default-block to something else.
Here is an example configuration using Fastmail's servers:
# Example for a system wide configuration file # A system wide configuration file is optional. # If it exists, it usually defines a default account. # This allows msmtp to be used like /usr/sbin/sendmail. account previous_default # The SMTP smarthost. host mailhub.oursite.example # Construct envelope-from addresses of the form "firstname.lastname@example.org". #auto_from on #maildomain oursite.example # Use TLS. #tls on #tls_trust_file /etc/ssl/certs/ca-certificates.crt # Syslog logging with facility LOG_MAIL instead of the default LOG_USER. syslog LOG_MAIL #//////DEFAULT END////// account default host mail.messagingengine.com from email@example.com auth on user firstname.lastname@example.org password your-password-here tls on tls_starttls off
The part below
#//////DEFAULT END////// contains our changes with the exception of the line
account previous_default, which was originally
Unless you happen to use Fastmail, replace
mail.messagingengine.com with whatever the IMAP server address for your provider is. You might also need to enable the
echo -e "Subject: Test mail\n\nThis is a test \"message\"." | sendmail -f "Sender's Name <email@example.com>" firstname.lastname@example.org
Note that sendmail (
/usr/sbin/sendmail) is a symlink to
|mini-sendmail||1.3.6-4||none||5866|| mini_sendmail reads its standard input up to an end-of-file and sends a copy of the message found there to all of the addresses listed. The message is sent by connecting to a local SMTP server. This means
opkg install mini-sendmail
On Chaos Calmer, the package is no longer available, but the version from Barrier Breaker still works (AA & BB versions as installed below work in AA):
opkg install http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/oldpackages/mini-sendmail_1.3.6-4_ar71xx.ipk
mini_sendmail -ssmtp.mail.yahoo.com -p465 -t email@example.com < input_file usage: mini_sendmail [-f<name>] [-t] [-s<server>] [-p<port>] [-T<timeout>] [-v] [address ...]
Note that there must not be a space between the option and the value; e.g. “-p 465” is incorrect.
Several sample configurations found on the internet failed, but as of 160413, this worked
echo -e 'From: firstname.lastname@example.org\r\nSubject: Test Subject\r\n\r\nTesting\r\n.' | mini_sendmail -email@example.com -smail.brighthouse.com toAddr@gmail.com
smtp.gmail.com failed; omitting -f failed; omitting “From: ” resulted in transmission, but no sender shown.
This is a very small package if you can find an smtp server which works and you can configure the command so that the server accepts it.
A secure, effective and simple way of getting mail off a system to your mail hub. It contains no suid-binaries or other dangerous things - no mail spool to poke around in, and no daemons running in the background. mail is simply forwarded to the configured mailhost. Extremely easy configuration.
opkg install ssmtp
ssmtp expects its two configuration files named
/etc/ssmtp/ssmtp.conf. Both are self-explaining:
# /etc/ssmtp/ssmtp.conf firstname.lastname@example.org mailhub=mail.gmx.net:465 rewriteDomain=gmx.net hostname=gmx.net FromLineOverride=YES UseTLS=YES #UseSTARTTLS=YES
# /etc/ssmtp/revaliases # Format: local_account:outgoing_address:mailhub root:email@example.com:mail.gmx.net:465
To use the program, with SMTP auth:
cat /etc/banner | ssmtp -vvv -firstname.lastname@example.org -ap123password456 email@example.com