How to send mail from an OpenWrt router
I am using OpenWrt 10.03 and need to send "reports" from my router by email. I have installed sendmail:
# opkg install mini-sendmail
Then I used my ISP's smtp server:
# echo -e "From: [email protected]\nSubject: SUBJECT\nReply-to: [email protected]\n\nBODYHERE" \
> | mini_sendmail -sMYISPSSMTPSERVER [email protected]
mini_sendmail: unexpected response 550 to RCPT TO command
Questions:
-
How could I know, that my ISP's blocking port 25?
# telnet MYISPSSMTPSERVER 25 220 MYISPSSMTPSERVER ESMTP ready quit 221 MYISPSSMTPSERVER closing connection Connection closed by foreign host
so it's not blocked?
If port 25 isn't blocked, then how could I check this? Do I need an "email user" at my ISP?
- If I can't get email working, than I have to register a free e-mail address [gmail?], and find out, how to send e-mail [with username and password required] in OpenWRT The only problem is that, I don't want to store passwords on the router.
Solution 1:
I know this is old, but it's one of the links that come up when searching "openwrt smtp"
Follow this link-
https://forum.openwrt.org/viewtopic.php?id=18669
For sake of preventing linkrot issues..
First install.
# opkg install msmtp
Then create config file.
# cat /etc/msmtprc
account default
host smtp.gmail.com
port 587
auth on
user [email protected]
password password
auto_from off
from [email protected]
tls on
tls_starttls on
tls_certcheck off
logfile
syslog LOG_MAIL
To email, use the usual sendmail approach.
Solution 2:
Solution: I installed ssmtp + registered a free email address with ssl smtp as follows:
# opkg install ssmtp
$ cat /etc/ssmtp/ssmtp.conf
[email protected]
mailhub=SMTP.EXAMPLE.COM:465
rewriteDomain=EXAMPLE.COM
hostname=EXAMPLE.COM
FromLineOverride=YES
UseTLS=YES
AuthUser=MYEMAIL
AuthPass=PASSWORDHERE
$ echo -e "From: [email protected]\nSubject: SUBJECT\nReply-to: [email protected]\n\nBODYHERE" \
> | ssmtp -vvv [email protected]
Solution 3:
Can you take the router out of the equation and just send an email through telnet? ISPs will often block outbound SMTP (tcp/25) altogether while permitting connections to their mail server, which you can use as a smarthost (that might require authentication) to relay mail for you.