lua-resty-mail icon indicating copy to clipboard operation
lua-resty-mail copied to clipboard

yahoo smtp issues

Open sparvu opened this issue 6 years ago • 2 comments

We have switched to use your Lua library for sending emails within OpenResty. It works fine for Google, our own SMTP server 465 and submission 587.

However on Yahoo, we are seeing problems. The errors, received on 465 or 587 are same:

2019/06/29 18:01:59 [warn] 87569#0: *323 [lua] email.lua:60: mailer:send error: /opt/kronometrix/mesg/lualib/resty/mail/smtp.lua:129: SMTP response was not successful: 535 5.7.0 (#AUTH005) Too many bad auth attempts., client: 127.0.0.1, server: , request: "POST /send_mail HTTP/1.1", host: "127.0.0.1:9000"
2019/06/29 18:03:34 [warn] 87569#0: *327 [lua] email.lua:60: mailer:send error: /opt/kronometrix/mesg/lualib/resty/mail/smtp.lua:129: SMTP response was not successful: 535 5.7.0 (#AUTH005) Too many bad auth attempts., client: 127.0.0.1, server: , request: "POST /send_mail HTTP/1.1", host: "127.0.0.1:9000"

2019/06/29 18:07:14 [warn] 87569#0: *334 [lua] email.lua:60: mailer:send error: /opt/kronometrix/mesg/lualib/resty/mail/smtp.lua:129: SMTP response was not successful: 535 5.7.0 (#AUTH005) Too many bad auth attempts., client: 127.0.0.1, server: , request: "POST /send_mail HTTP/1.1", host: "127.0.0.1:9000"

Can you please test your library with Yahoo services ? Thanks.

sparvu avatar Jun 29 '19 18:06 sparvu

@sparvu: I believe this is because Yahoo disables standard SMTP PLAIN and LOGIN authentication mechanisms by default (similar to Gmail). Instead, it prefers the XOAUTH2 authentication mechanism, which is not something lua-resty-mail currently supports. If you'd like to use lua-resty-mail with Yahoo Mail, it should be possible as long as you enable the option to "Allow apps that use less secure sign in" (a similar requirements is necessary if trying to send standard SMTP mail with Gmail). Here's an article that explains this fairly well (including whether or not you should be concerned about this "less secure" option): https://foundry376.zendesk.com/hc/en-us/articles/115001882372-Authorizing-Use-with-Yahoo

With that option enabled, I was then able to successfully send mail via Yahoo with this snippet:

local mailer, mailer_err = mail.new({
  host = "smtp.mail.yahoo.com",
  port = 587,
  username = "[email protected]",
  password = "YOUR_PASSWORD",
})

local ok, err = mailer:send({
  from = "[email protected]",
  to = { "[email protected]" },
  subject = "Your Subject",
  text = "Your Message",
})

Adding support for XOAUTH2 might be the best option for lua-resty-mail, although that's not something I personally need, so pull requests would be welcome. Most language SMTP libraries don't seem to support this authentication mechanism out of the box, since I think it's predominantly used by the likes of Gmail and Yahoo for personal mail services. But here's a few other implementations/notes: https://github.com/nfo/gmail_xoauth https://github.com/andris9/xoauth2 https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2

GUI avatar Jul 21 '19 01:07 GUI

right. thanks for comments. will try the settings for Yahoo. Of course would be sweet to have XOAUTH2 support.

sparvu avatar Jul 22 '19 11:07 sparvu