In this page I describe how to send an email through a router (Asus RT-AC56U)
- we use an Entware installation, so please
refer to this page on how to install Entware on a router.
To send an email, we use a command line utility called "msmtp", compatible with most used command line utility "sendmail" (not included in Entware packages).
To install package "msmtp" we use the command line "opkg install msmtp".
After installing this package, we must setup the configuration file "/opt/etc/msmtprc". This file include all data regarding the SMTP server, these data must be provided by the email provider.
For more information about configuration file, please refer to this website.
This is a simple configuration file, we use Microsoft's Live SMTP server :
cat /opt/etc/msmtprc account default domain local host smtp.live.com port 25 protocol smtp from [myemail]@hotmail.com auth on user [myemail]@hotmail.com password [mypassword] tls on tls_starttls on tls_certcheck off syslog LOG_MAIL
Then we can use a script to send an email. This is a simple script used to send an email through "msmtp" command line utility - please remember that "from" email address of the script must be the same of the "from" email address of the configuration file:
#!/bin/sh msmtp -v -t << EOF From: [myemail]@hotmail.com Subject: Router - sample email test To: email@example.com This is a testing email sent by router through Entware. EOF exit 0