<i id='AzxVb'><tr id='AzxVb'><dt id='AzxVb'><q id='AzxVb'><span id='AzxVb'><b id='AzxVb'><form id='AzxVb'><ins id='AzxVb'></ins><ul id='AzxVb'></ul><sub id='AzxVb'></sub></form><legend id='AzxVb'></legend><bdo id='AzxVb'><pre id='AzxVb'><center id='AzxVb'></center></pre></bdo></b><th id='AzxVb'></th></span></q></dt></tr></i><div id='AzxVb'><tfoot id='AzxVb'></tfoot><dl id='AzxVb'><fieldset id='AzxVb'></fieldset></dl></div>
    <tfoot id='AzxVb'></tfoot>

    <legend id='AzxVb'><style id='AzxVb'><dir id='AzxVb'><q id='AzxVb'></q></dir></style></legend>

        <bdo id='AzxVb'></bdo><ul id='AzxVb'></ul>

      <small id='AzxVb'></small><noframes id='AzxVb'>

      1. 通过 SMTP Gmail Oauth2 问题发送邮件

        send mail via SMTP Gmail Oauth2 issue(通过 SMTP Gmail Oauth2 问题发送邮件)
        <legend id='2ysRU'><style id='2ysRU'><dir id='2ysRU'><q id='2ysRU'></q></dir></style></legend>

            <tbody id='2ysRU'></tbody>

          <small id='2ysRU'></small><noframes id='2ysRU'>

          • <i id='2ysRU'><tr id='2ysRU'><dt id='2ysRU'><q id='2ysRU'><span id='2ysRU'><b id='2ysRU'><form id='2ysRU'><ins id='2ysRU'></ins><ul id='2ysRU'></ul><sub id='2ysRU'></sub></form><legend id='2ysRU'></legend><bdo id='2ysRU'><pre id='2ysRU'><center id='2ysRU'></center></pre></bdo></b><th id='2ysRU'></th></span></q></dt></tr></i><div id='2ysRU'><tfoot id='2ysRU'></tfoot><dl id='2ysRU'><fieldset id='2ysRU'></fieldset></dl></div>
            <tfoot id='2ysRU'></tfoot>
                • <bdo id='2ysRU'></bdo><ul id='2ysRU'></ul>

                  本文介绍了通过 SMTP Gmail Oauth2 问题发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我可以按照 谷歌示例.

                  但现在的问题是我无法发送邮件.每当我尝试发送邮件时,我都会收到以下错误.

                  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 http://support.google.com/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)
                  

                  首先我无法连接到本地主机,因此我在会话的属性中添加了几行代码,如下面的 OAuth2Authenticator 类,仍然成功验证.但发不出邮件.

                  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.com");
                  props.put("mail.smtp.port", "587");
                  

                  我正在使用相同的会话对象和 SMTP 传输对象,当我第一次成功进行身份验证时,它将从 OAuth2Authenticator 类返回.

                  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);
                  

                  完整的调试日志

                  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.com", port 587, isSSL false
                  220 mx.google.com ESMTP gj1sm1027169pbc.11 - gsmtp
                  DEBUG SMTP: connected to host "smtp.gmail.com", port: 587
                  
                  EHLO E6410-PC
                  250-mx.google.com 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.com 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.com", port 587, isSSL false
                  220 mx.google.com ESMTP az8sm1466819pab.3 - gsmtp
                  DEBUG SMTP: connected to host "smtp.gmail.com", port: 587
                  
                  EHLO E6410-PC
                  250-mx.google.com 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.com 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.com>
                  530-5.5.1 Authentication Required. Learn more at
                  530 5.5.1 http://support.google.com/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 http://support.google.com/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 http://support.google.com/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)
                  

                  我现在像这样明确地调用 AUTH 命令.

                  Edited: I now called AUTH command explicitly like that .

                   byte[] response = String.format("user=%s1auth=Bearer %s11",
                                      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: 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.com", port 587, isSSL false
                  220 mx.google.com ESMTP kl3sm6965596pbc.15 - gsmtp
                  DEBUG SMTP: connected to host "smtp.gmail.com", port: 587
                  
                  EHLO E6410-PC
                  250-mx.google.com 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.com 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.com", port 587, isSSL false
                  220 mx.google.com ESMTP vo6sm6969236pbc.8 - gsmtp
                  DEBUG SMTP: connected to host "smtp.gmail.com", port: 587
                  
                  EHLO E6410-PC
                  250-mx.google.com 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.com 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.com>
                  530-5.5.1 Authentication Required. Learn more at
                  530 5.5.1 http://support.google.com/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 http://support.google.com/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 http://support.google.com/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 http://support.google.com/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)
                  

                  推荐答案

                  对不起,答案在这里:Javamail api in android using XOauth 我测试过,它可以工作.

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

                  SMS 样式登录"失败 - 使用 2 步登录(通过电话 SMS)的安全帐户拒绝通过 SMTP 发送电子邮件(RAW 密码和 OAuth 样式,失败并出现身份验证错误).他们将允许您创建 OAuth 令牌,但不会发送电子邮件.

                  "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 问题发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)
                    <tbody id='cja8z'></tbody>

                      <bdo id='cja8z'></bdo><ul id='cja8z'></ul>

                      1. <legend id='cja8z'><style id='cja8z'><dir id='cja8z'><q id='cja8z'></q></dir></style></legend>
                          <tfoot id='cja8z'></tfoot>
                        1. <i id='cja8z'><tr id='cja8z'><dt id='cja8z'><q id='cja8z'><span id='cja8z'><b id='cja8z'><form id='cja8z'><ins id='cja8z'></ins><ul id='cja8z'></ul><sub id='cja8z'></sub></form><legend id='cja8z'></legend><bdo id='cja8z'><pre id='cja8z'><center id='cja8z'></center></pre></bdo></b><th id='cja8z'></th></span></q></dt></tr></i><div id='cja8z'><tfoot id='cja8z'></tfoot><dl id='cja8z'><fieldset id='cja8z'></fieldset></dl></div>

                            <small id='cja8z'></small><noframes id='cja8z'>