muquit / mailsend

A program to send mail via SMTP from command line
Other
298 stars 68 forks source link

Unable to send email with mailsend in OpenWrt #156

Closed cliffordanup closed 4 years ago

cliffordanup commented 4 years ago

Hello,

I just installed the mailsend with ssl binary from the OpenWrt Repository. When I attempt to send an email, it just doesn't want to work with all the openssl dependencies installed. Here is the command and output of the mailsend command.

` root@OpenWrt_Netgear_R6220:~# mailsend -f "xyz@hotmail.com" -t "xyz@hotmail.com" -ssl -user "xyz@hotmail.com" -pass 'abcdefghijklmnop' -smtp 'smtp-mail.outlook.com' -sub "Test Email from OpenWrt" -msg-body "Test Email from OpenWrt" Error: turn_on_raw_ssl: SSL connection failed

2012839556:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:332: Error: Expected smtp code 220, got 0

Could not send mail `

The following are all the installed programs of openssl, mailsend and luci (OpenWrt Web Interface with https using openssl)

root@OpenWrt_Netgear_R6220:~# opkg list-installed | egrep "ssl|luci|mailsend" liblucihttp-lua - 2019-07-05-a34a17d5-1 liblucihttp0 - 2019-07-05-a34a17d5-1 libopenssl-conf - 1.1.1g-1 libopenssl1.1 - 1.1.1g-1 libustream-openssl20150806 - 2020-03-13-40b563b1-1 luci - git-20.247.75781-0d0ab01-1 luci-app-firewall - git-20.247.75781-0d0ab01-1 luci-app-nlbwmon - git-20.260.30581-915a64c-1 luci-app-opkg - git-20.247.75781-0d0ab01-1 luci-base - git-20.247.75781-0d0ab01-1 luci-compat - git-20.247.75781-0d0ab01-1 luci-lib-ip - git-20.247.75781-0d0ab01-1 luci-lib-jsonc - git-20.247.75781-0d0ab01-1 luci-lib-nixio - git-20.247.75781-0d0ab01-1 luci-mod-admin-full - git-20.247.75781-0d0ab01-1 luci-mod-network - git-20.247.75781-0d0ab01-1 luci-mod-status - git-20.247.75781-0d0ab01-1 luci-mod-system - git-20.247.75781-0d0ab01-1 luci-proto-ipv6 - git-20.247.75781-0d0ab01-1 luci-proto-ppp - git-20.247.75781-0d0ab01-1 luci-ssl-openssl - git-20.260.30581-915a64c-1 luci-theme-bootstrap - git-20.247.75781-0d0ab01-1 mailsend - 1.19-2 openssl-util - 1.1.1g-1 rpcd-mod-luci - 20191114 uwsgi-luci-support - 2.0.18-1

muquit commented 4 years ago

mailsend works with openssl 1.1.1g. I don't have access to OpenWrt, so can't tell what's gong on. Did you try to get the info about the server using StartTLS? e.g.

mailsend -info -smtp smtp-mail.outlook.com -port 587

You specified -ssl but I don't see the port you specified.

Thanks.

cliffordanup commented 4 years ago

I got this issue resolved. I had to use the -starttls and -auth parameters along with the -user and -pass parameters for this to work. I had better luck in using Google's SMTP smtp.gmail.com than Outlook's smtp-mail.outlook.com. For some reason, Outlook used to fail with the following error most of the times and used to work only once when the same command was tried 4-5 times, not sure what was going on there:

root@OpenWrt_Netgear_R6220:~# mailsend -f "xyz@hotmail.com" -t "xyz@xyz.com" -smtp "smtp-mail.outlook.com" -starttls -auth-login -user "xyz@hotmail.com" -pass "abcdefghijklmnop" -sub "Test from OpenWrt" -M "Test from OpenWrt" Socket Error: [11]: Resource temporarily unavailable Error: Connection is closed unexpectedly Error: AUTH LOGIN failed: '-1 ' Could not send mail