This repository has been archived by the owner on Dec 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Sending Email
RMerl edited this page Oct 11, 2012
·
24 revisions
Asuswrt-Merlin includes a cutdown version of sendmail which can be used to send mail from the router. Basic usage will look like this:
echo "This is a test email." | /usr/sbin/sendmail -S"smtp.yourisp.com" -f"[email protected]" [email protected]
You can send a more proper Email by writing the mail to a file, and then piping it to sendmail. The following example, if saved as a wan-start script, will make your router send you an Email whenever the WAN interface comes up, containing the WAN IP:
#!/bin/sh
SMTP="smtp.yourisp.com"
FROM="[email protected]"
FROMNAME="Your Router"
TO="[email protected]"
echo "Subject: WAN state notification" >/tmp/mail.txt
echo "From: \\"$FROMNAME\\"<$FROM>" >>/tmp/mail.txt
echo "I just got connected to the Interwebz." >>/tmp/mail.txt
echo "My new IP is: `nvram get wan0_ipaddr`" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "--- " >>/tmp/mail.txt
echo "Your friendly router." >>/tmp/mail.txt
cat /tmp/mail.txt | /usr/sbin/sendmail -S"$SMTP" -f"$FROM" $TO
rm /tmp/mail.txt
If your SMTP server requires authentication, you can pass them as additional arguments. To see the available options, just run "sendmail -h".