Send Email with Msmtp on OpenWrt

Msmtp is an SMTP client it it transmits a mail to an SMTP server (for example at a free mail provider) which takes care of further 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. With Msmtp on OpenWrt you able to send e-mail using a command or code script.


Minimum free space size requirement = (2.5 MB)

Installation and Configuration

Step 1: Install Msmtp
  1. Select Tabs System - Software
  2. Select Update List
  3. In download and install packages type "msmtp" then click ok
Step 2. Configure Msmtp
  1. cd /etc
  2. vi msmtprc *If there are no msmtprc files, add the files by "touch msmtprc" command
You need to edit it or add it
  • account default
  • host mailhub.oursite.example ---> host
  • port 587 *add port
  • #tls on *remove hashtag to --> tls on
  • #tls_trust_file /etc/ssl/certs/ca-certificates.crt *replace with ---> tls_certcheck off
  • *and add under / below syslog LOG_MAIL*
    • auth login
    • user
    • password gmailpassword
    • from


Run this command from SSH on your router:
echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp --debug --from=default -t
Then check the destination email inbox.

Additional Msmtp options parameters

  • --debug *If you want to see log of sending mail
  • --from=default *It's default account located in /etc/msmtprc
  • -t username[at] *It will send email to the destination email


  1. Installing and Configuring mSMTP - VigasDeep
  2. Image by Cairo on Flickr used under CC BY 2.0 / Add More Shadow


  1. You have shared amazing post. This post is really helpful for us to know the information. Thank you for taking your time to post such a wonderful article. SMTP Server for Bulk Email


Post a Comment