I am trying to send email using mailsend command, but it keeps failing with the following error messages:
Error: Connection to smtp.gmail.com:25 timed out after 5 seconds
Error: Could not connect to SMTP server "smtp.gmail.com" at port 25
Could not send mail
This was working fine and I even received a few emails. Not sure what happened, all of a sudden my emails stopped getting delivered.
I enabled firewall logging for both the lan interface and the wan interface, but I don't observe any rules blocking / dropping this transaction.
My previous investigations of this showed that neither the mailsend nor msmtp packages send the gmail required headers in emails. Same goes for other big email providers.
Gmail will usually allow a limited number of these emails through, sending a warning/error in reply. After this the sending ip address will be blacklisted for a few days.
I tried using smtplib.sendmail() in python in one of my clients to the same gmail smtp server, it seems to work fine. Even Send-MailMessage on powershell on my windows client is able to send the email. I tried both these on port 587.
It continues to fail on my router though even after trying to use port 587.
Error: Connection to smtp.gmail.com:587 timed out after 5 seconds
Error: Could not connect to SMTP server "smtp.gmail.com" at port 587
Could not send mail
This is my second openwrt router. I have the same mailsend command working fine in another openwrt router in another location and ISP.
The difference in this location is that, I have two ISP's configured in load balancing configuration using mwan3.
Hmm, interesting, I had scheduled the emails to send me a backup of my nlbwmon database files and usage statistics in separate emails at the same schedule on both my routers.
Will this cause mailsend to use the same Message-ID? Should I typically schedule them many a few mins apart?
Needless to say, I was using the same smtp server, from address, to address and app password for my authentication in both my bash scripts.
HELO is the standard old-fashioned "hello".
EHLO is Extended HELO and asks the server to use extended protocol.
See "Part 2" of your above samlogic link.
When I give nc smtp.gmail.com 587, it responds saying ESMTP. From the article I am supposed to give EHLO in this case. With basic SMTP I wouldn't probably be able to send an email anyway, because I see no way of authenticating myself.
Apparently this was an IPv6 Problem. Out of both my ISP's, only one had IPv6 Prefix Delegated and that too a /64 address. So, I enabled IPv6 Suffix on my lan interface and enabled my wan6 interface, added the necessary members, policy and rule to route ONLY IPv6 Traffic through the newly enabled wan6 interface.
This solved the problem. Thanks to One Marc Fifty's YouTube channel explaining IPv6 from scratch.