Error handling for email.Send()

177 views
Skip to first unread message

Eric Geer

unread,
Nov 17, 2016, 3:12:34 AM11/17/16
to DroidScript
I keep getting random results for my sending of emails using email.send().  My latest is this:

WARNING: Failed to send email: Could not connect to SMTP host: 68.87.20.6, port: 587

Oddly, If I stop the script and play it again it will start sending again.  I have no idea why.  Would like to see exactly what's going on as far as SMTP transmissions and debugging if that is available.

Eric Geer

unread,
Nov 23, 2016, 9:45:06 PM11/23/16
to DroidScript
I still need help with this. Seems it gave up entirely now.  says it cant connect to SMTP host, but I have no idea why.  internet is working.
Message has been deleted

Eric Geer

unread,
Nov 24, 2016, 12:24:21 AM11/24/16
to DroidScript
of course.  I'm using the sample code and substituting my own account and server.  I've been over them 20-30 times now.  I need a way to debug this.

Dave Smart

unread,
Nov 25, 2016, 12:05:24 PM11/25/16
to DroidScript
Hi Eric,

Assuming you have turned on the option for "Less secure" connections in Gmail, then I think that you might be falling foul of Googles AI

I found this information in the description of the node npm package called 'nodemailer'

Even though Gmail is the fastest way to get started with sending emails, it is by no means a preferable solution unless you are using OAuth2 authentication. Gmail expects the user to be an actual user not a robot so it runs a lot of heuristics for every login attempt and blocks anything that looks suspicious to defend the user from account hijacking attempts. For example you might run into trouble if your server is in another geographical location – everything works in your dev machine but messages are blocked in production.

Additionally Gmail has came up with the concept of 'less secure' apps which is basically anyone who uses plain password to login to Gmail, so you might end up in a situation where one username can send (support for 'less secure' apps is enabled) but other is blocked (support for 'less secure' apps is disabled). When using this method make sure to enable the required functionality by completing the "captcha enable". Without this, less secure connections won't work.

To prevent having login issues you should either use XOAUTH2 (see details here) or use another provider and preferably a dedicated one like Mailgun or SendGrid or any other. Usually these providers have free plans available that are comparable to the daily sending limits of Gmail. Gmail has a limit of 500 recipients a day (a message with one To and one Cc address counts as two messages since it has two recipients) for @gmail.com addresses and 2000 for Google Apps customers, larger SMTP providers usually offer about 200-300 recipients a day for free.



https://www.npmjs.com/package/nodemailer



Eric Geer

unread,
Nov 25, 2016, 7:26:10 PM11/25/16
to DroidScript
Comcast blocks all smtp traffic accept for their servers, so I can't use gmail. I have to use smtp.comcast.com on port 587. It was working, then it stopped, without me modifying the smtp or auth settings. This leads me to believe its either a bug, or Comcast is doing something else to prevent me from mailing out. The ONLY way to fix this is to see the smtp information as it attempts to connect and send. Otherwise, I'd be perfectly happy with using something like Pushbullet, but no one has replied to the thread about authentication and data in the header on an http post.

Eric Geer

unread,
Dec 6, 2016, 1:25:31 AM12/6/16
to DroidScript
OK, so I got my Leelbox setup as a second point of reference, and am getting the same error:


WARNING: Failed to send email: Could not connect to SMTP host: 68.87.20.6, port: 587

It works though if I setup a basic iPhone with SMTP pop account, so I have no idea why DroidScript is having issues.
Reply all
Reply to author
Forward
0 new messages