通过SMTP Gmail Oauth2问题发送邮件

编程入门 行业动态 更新时间:2024-10-28 06:35:50
本文介绍了通过SMTP Gmail Oauth2问题发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我可以通过谷歌示例。

但现在的问题是我无法发送邮件。

com.sun.mail.smtp.SMTPSendFailedException:530- 5.5.1需要验证。请通过 530了解详情,网址为com.sun.mail,网址为support.google/mail/bin/answer.py?answer=14257 f5sm19578172pav.22 。 smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2114) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1618) at com.sun.mail.smtp.SMTPTransport。 sendMessage(SMTPTransport.java:1119)在javax.mail.Transport.send0(Transport.java:195)在javax.mail.Transport.send(Transport.java:124)

首先,我得到无法连接到本地主机,因此我添加了几行代码来执行会话下面到OAuth2Authenticator类,仍然成功地进行了身份验证。但不能发送邮件。

props.put(mail.smtp.host,smtp.gmail。 COM); props.put(mail.smtp.port,587);

我使用同一会话对象和SMTP传输对象当我第一次验证成功时,从OAuth2Authenticator类返回。

Message message = new MimeMessage(session); message.setFrom(new InternetAddress(msg.getFrom())); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(msg.getTo())); message.setSubject(msg.getSubject()); message.setText(msg.getBody()); transport.send(message);

完整调试日志

DEBUG:setDebug:JavaMail版本1.4.5 DEBUG SMTP:启用SASL DEBUG SMTP:useEhlo true,useAuth false DEBUG SMTP:尝试连接到主机smtp .gmail,端口587,isSSL false 220 mx.google ESMTP gj1sm1027169pbc.11 - gsmtp DEBUG SMTP:连接到主机smtp.gmail,端口:587 EHLO E6410-PC 250-mx.google为您服务,[202.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES DEBUG SMTP:找到扩展名SIZE,参数35882577 DEBUG SMTP:找到扩展名8BITMIME,arg DEBUG SMTP:已找到扩展名STARTTLS,arg DEBUG SMTP:找到扩展名ENHANCEDSTATUSCODES,arg STARTTLS 220 2.0.0准备启动TLS EHLO E6410 -PC 250-mx.google为您服务,[202.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 25 0 ENHANCEDSTATUSCODES DEBUG SMTP:找到扩展名SIZE,arg35882577 DEBUG SMTP:找到扩展名8BITMIME,arg DEBUG SMTP:找到扩展名AUTH,arg LOGIN PLAIN XOAUTH XOAUTH2 DEBUG SMTP:找到扩展名ENHANCEDSTATUSCODES,arg DEBUG SMTP:通过SASL 进行身份验证DEBUG SMTP:允许SASL机制:XOAUTH2 DEBUG SMTP: SASL AUTH命令跟踪被抑制 DEBUG SMTP SASL:机制:XOAUTH2 DEBUG SMTP SASL:SASL客户端XOAUTH2 DEBUG SMTP SASL:回调长度:1 DEBUG SMTP SASL:回调0: javax.security.auth.callback.NameCallback@100ab23 DEBUG SMTP SASL:无响应成功通过SMTP认证。 NOOP 250 2.0.0 OK gj1sm1027169pbc.11 - gsmtp SMTP仍然连接:true DEBUG:getProvider()返回javax.mail.Provider [TRANSPORT,smtp,com .sun.mail.smtp.SMTPTransport,Sun Microsystems,Inc] DEBUG SMTP:启用SASL DEBUG SMTP:useEhlo true,useAuth false DEBUG SMTP:尝试连接到主机smtp。 gmail,端口587,isSSL false 220 mx.google ESMTP az8sm1466819pab.3 - gsmtp DEBUG SMTP:连接到主机smtp.gmail,端口:587 EHLO E6410-PC 250-mx.google为您服务,[202.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES DEBUG SMTP:找到扩展名SIZE,arg35882577 DEBUG SMTP:找到扩展名8BITMIME,arg DEBUG SMTP :发现扩展名STARTTLS,arg DEBUG SMTP:发现扩展名ENHANCEDSTATUSCODES,arg STARTTLS 220 2.0.0准备启动TLS EHLO E6410- PC 250-mx.google为您服务,[202.xxx .xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 250 ENHANCEDSTATUSCODES DEBUG SMTP:找到扩展名SIZE, arg35882577 DEBUG SMTP:找到扩展名8BITMIME,arg DEBUG SMTP:找到扩展名AUTH,argLOGIN PLAIN XOAUTH XOAUTH2 DEBUG SMTP: ENHANCEDSTATUSCODES,arg DEBUG SMTP:use8bit false MAIL FROM:< user@gmail> 530-5.5.1需要验证。在 530处了解详情5.5.1 support.google/mail/bin/answer.py?answer=14257 az8sm1466819pab.3 - gsmtp DEBUG SMTP:获得响应代码530回应:530-5.5.1需要验证。了解更多信息,请访问 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 az8sm1466819pab.3 - gsmtp RSET 250 2.1.5刷新az8sm1466819pab.3 - gsmtp DEBUG SMTP:MessagingException发送时com.sun.mail.smtp.SMTPSendFailedException:530-5.5.1需要身份验证。请通过 530了解详情5.5.1 support.google/mail/bin/answer.py?answer=14257 az8sm1466819pab.3 - gsmtp 在com.sun上。 mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2114) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1618) at com.sun.mail.smtp。 SMTPTransport.sendMessage(SMTPTransport.java:1119),位于javax.mail.Transport.send0(Transport.java:195)

编辑:我现在明确称为AUTH命令。

byte [] response = String.format(user =%s\1auth = Bearer%s\1\1, emailAddress,accessToken.getToken())。getBytes(); response = BASE64EncoderStream.encode(response); System.out.println(token check:+ new String(response)); transport.issueCommand(AUTH XOAUTH2+ new String(response),235);

但回应仍然相同。

<$ $ DEBUG:JavaMail版本1.4.5 DEBUG SMTP:启用SASL DEBUG SMTP:useEhlo true,useAuth false DEBUG SMTP:尝试连接托管smtp.gmail,端口587,isSSL false 220 mx.google ESMTP kl3sm6965596pbc.15 - gsmtp DEBUG SMTP:连接到主机smtp.gmail,端口:587 EHLO E6410-PC 250-mx.google为您服务,[xxx.xxx.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES DEBUG SMTP:找到扩展名SIZE,arg35882577 DEBUG SMTP:找到扩展名8BITMIME,arg DEBUG SMTP:找到了扩展名STARTTLS,arg DEBUG SMTP:找到了扩展名ENHANCEDSTATUSCODES,arg STARTTLS 220 2.0.0准备启动TLS EHLO E6410-PC 250-mx.google为您服务,[xxx.xxx.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250 -AUTH LOGIN PLAIN XOAU TH XOAUTH2 250 ENHANCEDSTATUSCODES DEBUG SMTP:找到扩展名SIZE,arg35882577 DEBUG SMTP:找到扩展名8BITMIME,arg DEBUG SMTP: AUTH,argLOGIN PLAIN XOAUTH XOAUTH2 DEBUG SMTP:找到扩展名ENHANCEDSTATUSCODES,arg成功验证到SMTP。 令牌检查:abcdefgFuYUBnbWFpbC5jb20BYXV0aD1CZWabcdefgSEVTNlpUVlFTUXZfblZfZ01FaDF6WWtSQ2kzb1d5RElFQ19mb2NmWG5Sam93RUlBYVJRTldfNwEB AUTH XOAUTH2 abcdefgFuYUBnbWFpbC5jb20BYXV0aD1CZWabcdefgSEVTNlpUVlFTUXZfblZfZ01FaDF6WWtSQ2kzb1d5RElFQ19mb2NmWG5Sam93RUlBYVJRTldfNwEB 235 2.7.0接受 NOOP 250 2.0.0 OK kl3sm6965596pbc.15 - gsmtp 是SMTP还是connected:true DEBUG:getProvider()返回javax.mail.Provider [TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems,Inc] DEBUG SMTP:启用SASL DEBUG SMTP:useEhlo true,useAuth false DEBUG SMTP:尝试连接到主机smtp.gmail,端口587,isSSL false 220 mx.google ESMTP vo6sm6969236pbc.8 - gsmtp DEBUG SMTP:连接到主机smtp.gmail,端口:587 EHLO E6410-PC 250-mx.google为您服务,[xxx .xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES DEBUG SMTP:找到扩展名SIZE ,arg35882577 DEBUG SMTP:找到扩展名8BITMIME,arg DEBUG SMTP:找到扩展名STARTTLS,arg DEBUG SMTP:找到扩展名ENHANCEDSTATUSCODES, arg STARTTLS 220 2.0.0准备启动TLS EHLO E6410-PC 250-mx.google为您提供服务,[xxx.xxx.xxx。 xxx] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 250 ENHANCEDSTATUSCODES DEBUG SMTP:找到扩展名SIZE,arg35882577 DEBUG SMTP:找到扩展名8BITMIME,arg DEBUG SMTP:找到扩展名AUTH,argLOGIN PLAIN XOAUTH XOAUTH2 DEBUG SMTP:找到扩展名ENHANCEDSTATUSCODES, arg DEBUG SMTP:use8bit false MAIL FROM:< user@gmail> 530-5.5.1需要验证。在 530处了解详情5.5.1 support.google/mail/bin/answer.py?answer=14257 vo6sm6969236pbc.8 - gsmtp DEBUG SMTP:获得响应代码530回应:530-5.5.1需要验证。了解更多信息,请点击 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 vo6sm6969236pbc.8 - gsmtp RSET 250 2.1.5刷新vo6sm6969236pbc.8 - gsmtp DEBUG SMTP:MessagingException发送时com.sun.mail.smtp.SMTPSendFailedException:530-5.5.1需要身份验证。要了解更多信息,请访问 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 vo6sm6969236pbc.8 - com.sun上的gsmtp 。 mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2114) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1618) at com.sun.mail.smtp。 SMTPTransport.sendMessage(SMTPTransport.java:1119)在javax.mail.Transport.send0上的(Transport.java:195)在javax.mail.Transport.send上的(Transport.java:124) QUIT 221 2.0.0关闭连接vo6sm6969236pbc.8 - gsmtp com.sun.mail.smtp.SMTPSendFailedException:530-5.5.1需要身份验证。要了解更多信息,请访问 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 vo6sm6969236pbc.8 - com.sun上的gsmtp 。 mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2114) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1618) at com.sun.mail.smtp。 SMTPTransport.sendMessage(SMTPTransport.java:1119)在javax.mail.Transport.send0上的(Transport.java:195)在javax.mail.Transport.send上的(Transport.java:124)

解决方案

抱歉的人,答案在这里:我测试过,它的工作原理。短信登录失败 - 通过2步登录(通过手机短信)拒绝通过SMTP发送电子邮件的安全帐户(包括RAW密码和OAuth样式,失败时带有授权错误)。他们会让您创建OAuth令牌,但不会发送电子邮件。

I can authenticated to SMTP by following the google example.

But the problem now is I can't send out the mail. I am getting the following error whenever I try to send out mail.

com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 f5sm19578172pav.22 at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2114) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1618) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1119) at javax.mail.Transport.send0(Transport.java:195) at javax.mail.Transport.send(Transport.java:124)

First I am getting can't connect to local host , thus I added a few lines of code to propery of session like below to OAuth2Authenticator class , still authenicated successfully. But can't send out the mail.

props.put("mail.smtp.host", "smtp.gmail"); props.put("mail.smtp.port", "587");

I am using the same session object and SMTP transport object which will be returned from OAuth2Authenticator class when I first authenticated successfully.

Message message = new MimeMessage(session); message.setFrom(new InternetAddress(msg.getFrom())); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(msg.getTo())); message.setSubject(msg.getSubject()); message.setText(msg.getBody()); transport.send(message);

Full Debug Log

DEBUG: setDebug: JavaMail version 1.4.5 DEBUG SMTP: enable SASL DEBUG SMTP: useEhlo true, useAuth false DEBUG SMTP: trying to connect to host "smtp.gmail", port 587, isSSL false 220 mx.google ESMTP gj1sm1027169pbc.11 - gsmtp DEBUG SMTP: connected to host "smtp.gmail", port: 587 EHLO E6410-PC 250-mx.google at your service, [202.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES DEBUG SMTP: Found extension "SIZE", arg "35882577" DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "STARTTLS", arg "" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" STARTTLS 220 2.0.0 Ready to start TLS EHLO E6410-PC 250-mx.google at your service, [202.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 250 ENHANCEDSTATUSCODES DEBUG SMTP: Found extension "SIZE", arg "35882577" DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH XOAUTH2" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" DEBUG SMTP: Authenticate with SASL DEBUG SMTP: SASL mechanisms allowed: XOAUTH2 DEBUG SMTP: SASL AUTH command trace suppressed DEBUG SMTP SASL: Mechanisms: XOAUTH2 DEBUG SMTP SASL: SASL client XOAUTH2 DEBUG SMTP SASL: callback length: 1 DEBUG SMTP SASL: callback 0: javax.security.auth.callback.NameCallback@100ab23 DEBUG SMTP SASL: no response Successfully authenticated to SMTP. NOOP 250 2.0.0 OK gj1sm1027169pbc.11 - gsmtp Is SMTP still connected: true DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc] DEBUG SMTP: enable SASL DEBUG SMTP: useEhlo true, useAuth false DEBUG SMTP: trying to connect to host "smtp.gmail", port 587, isSSL false 220 mx.google ESMTP az8sm1466819pab.3 - gsmtp DEBUG SMTP: connected to host "smtp.gmail", port: 587 EHLO E6410-PC 250-mx.google at your service, [202.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES DEBUG SMTP: Found extension "SIZE", arg "35882577" DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "STARTTLS", arg "" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" STARTTLS 220 2.0.0 Ready to start TLS EHLO E6410-PC 250-mx.google at your service, [202.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 250 ENHANCEDSTATUSCODES DEBUG SMTP: Found extension "SIZE", arg "35882577" DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH XOAUTH2" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" DEBUG SMTP: use8bit false MAIL FROM:<user@gmail> 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 az8sm1466819pab.3 - gsmtp DEBUG SMTP: got response code 530, with response: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 az8sm1466819pab.3 - gsmtp RSET 250 2.1.5 Flushed az8sm1466819pab.3 - gsmtp DEBUG SMTP: MessagingException while sending com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 az8sm1466819pab.3 - gsmtp at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2114) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1618) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1119) at javax.mail.Transport.send0(Transport.java:195)

Edited: I now called AUTH command explicitly like that .

byte[] response = String.format("user=%s\1auth=Bearer %s\1\1", emailAddress, accessToken.getToken()).getBytes(); response = BASE64EncoderStream.encode(response); System.out.println("token check : " + new String(response)); transport.issueCommand("AUTH XOAUTH2 " + new String(response), 235);

but the response still the same.

DEBUG: setDebug: JavaMail version 1.4.5 DEBUG SMTP: enable SASL DEBUG SMTP: useEhlo true, useAuth false DEBUG SMTP: trying to connect to host "smtp.gmail", port 587, isSSL false 220 mx.google ESMTP kl3sm6965596pbc.15 - gsmtp DEBUG SMTP: connected to host "smtp.gmail", port: 587 EHLO E6410-PC 250-mx.google at your service, [xxx.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES DEBUG SMTP: Found extension "SIZE", arg "35882577" DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "STARTTLS", arg "" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" STARTTLS 220 2.0.0 Ready to start TLS EHLO E6410-PC 250-mx.google at your service, [xxx.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 250 ENHANCEDSTATUSCODES DEBUG SMTP: Found extension "SIZE", arg "35882577" DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH XOAUTH2" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" Successfully authenticated to SMTP. token check : abcdefgFuYUBnbWFpbC5jb20BYXV0aD1CZWabcdefgSEVTNlpUVlFTUXZfblZfZ01FaDF6WWtSQ2kzb1d5RElFQ19mb2NmWG5Sam93RUlBYVJRTldfNwEB AUTH XOAUTH2 abcdefgFuYUBnbWFpbC5jb20BYXV0aD1CZWabcdefgSEVTNlpUVlFTUXZfblZfZ01FaDF6WWtSQ2kzb1d5RElFQ19mb2NmWG5Sam93RUlBYVJRTldfNwEB 235 2.7.0 Accepted NOOP 250 2.0.0 OK kl3sm6965596pbc.15 - gsmtp Is SMTP still connected: true DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc] DEBUG SMTP: enable SASL DEBUG SMTP: useEhlo true, useAuth false DEBUG SMTP: trying to connect to host "smtp.gmail", port 587, isSSL false 220 mx.google ESMTP vo6sm6969236pbc.8 - gsmtp DEBUG SMTP: connected to host "smtp.gmail", port: 587 EHLO E6410-PC 250-mx.google at your service, [xxx.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES DEBUG SMTP: Found extension "SIZE", arg "35882577" DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "STARTTLS", arg "" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" STARTTLS 220 2.0.0 Ready to start TLS EHLO E6410-PC 250-mx.google at your service, [xxx.xxx.xxx.xxx] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 250 ENHANCEDSTATUSCODES DEBUG SMTP: Found extension "SIZE", arg "35882577" DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH XOAUTH2" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" DEBUG SMTP: use8bit false MAIL FROM:<user@gmail> 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 vo6sm6969236pbc.8 - gsmtp DEBUG SMTP: got response code 530, with response: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 vo6sm6969236pbc.8 - gsmtp RSET 250 2.1.5 Flushed vo6sm6969236pbc.8 - gsmtp DEBUG SMTP: MessagingException while sending com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 vo6sm6969236pbc.8 - gsmtp at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2114) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1618) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1119) at javax.mail.Transport.send0(Transport.java:195) at javax.mail.Transport.send(Transport.java:124) QUIT 221 2.0.0 closing connection vo6sm6969236pbc.8 - gsmtp com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 support.google/mail/bin/answer.py?answer=14257 vo6sm6969236pbc.8 - gsmtp at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2114) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1618) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1119) at javax.mail.Transport.send0(Transport.java:195) at javax.mail.Transport.send(Transport.java:124)

解决方案

Sorry people, answer is here: Javamail api in android using XOauth I tested, it works.

"SMS style login" failure - Secure accounts with 2 step login (via phone SMS) reject sending email via SMTP (both RAW password & OAuth style, fail with a Authentication error). They will let you create the OAuth token but will not send email.

更多推荐

通过SMTP Gmail Oauth2问题发送邮件

本文发布于:2023-11-28 15:56:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643041.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送邮件   SMTP   Gmail

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!