muquit / mailsend

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

sending from gmail fails #132

Open ArtZL opened 6 years ago

ArtZL commented 6 years ago

I'm trying to send an email from a gmail account. Don't know why it fails. Any suggestions?

I know my user ID and password are ok because when I put in a bad ID, an error message says its a bad ID or pwd.

MY COMMAND LINE: mailsend -v -f MyGmailAcct@gmail.com" -t Someone@Somewhere.com -starttls -port 587 -auth -smtp smtp.gmail.com -user MyGmailAcct@gmail.com -pass MyPassword -sub "Testing Art's Email" -disposition inline -attach "body.txt" -log "c:\temp\log.txt"

LOG FILE 17-May-2018 20:18:35.137: mailsend v@(#) mailsend v1.20b 17-May-2018 20:18:35.137: Connecting to smtp.gmail.com:587 17-May-2018 20:18:35.137: Will detect IPv4 or IPv6 automatically 17-May-2018 20:18:36.824: [S] 220 smtp.gmail.com ESMTP 15-v6sm2807902oix.25 - gsmtp 17-May-2018 20:18:36.825: [C] EHLO localhost

17-May-2018 20:18:37.827: [S] 250-smtp.gmail.com at your service, [2600:1702:27c0:42b0:99e:94d1:a4b0:cc67] 17-May-2018 20:18:37.828: [S] 250-SIZE 35882577 17-May-2018 20:18:37.828: [S] 250-8BITMIME 17-May-2018 20:18:37.829: [S] 250-STARTTLS 17-May-2018 20:18:37.830: [S] 250-ENHANCEDSTATUSCODES 17-May-2018 20:18:37.830: [S] 250-PIPELINING 17-May-2018 20:18:37.831: [S] 250-CHUNKING 17-May-2018 20:18:37.831: [S] 250 SMTPUTF8 17-May-2018 20:18:37.831: [C] STARTTLS

17-May-2018 20:18:38.827: [S] 220 2.0.0 Ready to start TLS 17-May-2018 20:18:40.825: [C] EHLO localhost

17-May-2018 20:18:41.823: [S] 250-smtp.gmail.com at your service, [2600:1702:27c0:42b0:99e:94d1:a4b0:cc67] 17-May-2018 20:18:41.824: [S] 250-SIZE 35882577 17-May-2018 20:18:41.824: [S] 250-8BITMIME 17-May-2018 20:18:41.824: [S] 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 17-May-2018 20:18:41.825: [S] 250-ENHANCEDSTATUSCODES 17-May-2018 20:18:41.825: [S] 250-PIPELINING 17-May-2018 20:18:41.825: [S] 250-CHUNKING 17-May-2018 20:18:41.825: [S] 250 SMTPUTF8 17-May-2018 20:18:41.826: Server does not support AUTH CRAM-MD5 17-May-2018 20:18:41.826: Using AUTH LOGIN 17-May-2018 20:18:41.826: [C] AUTH LOGIN

17-May-2018 20:18:42.825: [S] 334 VXNlcm5hbWU6 17-May-2018 20:18:42.826: [C] QXJ0TGllYmVybWFuQGdtYWlsLmNvbQ==

17-May-2018 20:18:43.828: [S] 334 UGFzc3dvcmQ6 17-May-2018 20:18:43.828: [C] QXJ0c0dvb2dsZUFjY3QhMQ==

17-May-2018 20:18:44.826: [S] 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbuo 17-May-2018 20:18:44.827: Error: AUTH LOGIN failed: '534 5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbuo' 17-May-2018 20:18:44.827: Could not send mail

muquit commented 6 years ago

Please login to the sender account in gmail and make sure that gmail is not blocking it. gmail does not allow sending mail from any "untrusted" app by default. If this is the case you have to configure gmail to allow it. Also if you are using windows, use double quotes around the sender's password.

Thanks.

ArtZL commented 6 years ago

Yes, you are correct. I have received an email from gmail saying they are blocking emails from this "untrusted" app. My program is used by churches who will be sending emails to their members. Some of those churches use Gmail for handling all of their email (incoming and outgoing). So, each church would have to "lower their shields" to allow untrusted apps. And they won't be willing to do that.

I'm just not sure what to do about this. Probably my only option would be to set up my own gmail account just for this purpose, and have all email from all churches come from this one account. Then use the -rt parameter with the church's actual email address.

ArtZL commented 6 years ago

Thanks for your quick and helpful response.

And thank you for the use of your program!

      Art

From: muquit Sent: Thursday, May 17, 2018 8:51 PM To: muquit/mailsend Cc: ArtZL ; Author Subject: Re: [muquit/mailsend] sending from gmail fails (#132)

Please login to the sender account in gmail and make sure that gmail is not blocking it. gmail does not allow sending mail from any "untrusted" app by default. If this is the case you have to configure gmail to allow it. Also if you are using windows, use double quotes around the sender's password.

Thanks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

muquit commented 6 years ago

gmail allows to generate an app specific password. This password can be used to send email instead of the regular user password. You can try that.

ArtZL commented 6 years ago

I’ve found that most online email services (gmail, yahoo, ...) put limits on the number of emails per day or per hour. For my application, limits are not acceptable. So I have the perfect work-around: I tell my users that email can be sent only from their own smtp account, not an online account. If they don’t have the right kind of account, they can’t do email.

I like that solution. It keeps things simple (for me).

     Thanks,   Art

From: muquit Sent: Thursday, May 17, 2018 9:56 PM To: muquit/mailsend Cc: ArtZL ; Author Subject: Re: [muquit/mailsend] sending from gmail fails (#132)

gmail allows to generate an app specific password. This password can be used to send email instead of the regular user password. You can try that.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

alejandro5042 commented 6 years ago

In addition,, you may want to look into services like https://sendgrid.com/ with its SMTP service.

atesin commented 11 months ago

don't use "EHLO localhost" envelope

chances are your message (and maybe your account) will be blocked

how it works?? ... you send the mail:

EHLO localhost
blah

suggestion: use a public domain that is correcty resolved from outside internet... your own domain, configured, or at least use some free ddns service/subdomain

muquit commented 11 months ago

Did you try the option -domain ?

mailsend -h 
...
-domain    domain     - domain name for SMTP HELO/EHLO
...

Thanks.