Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Email 为什么我得到一个nulljavax.mail.AuthenticationFailedException?_Email_Exception_Authentication_Jakarta Mail - Fatal编程技术网

Email 为什么我得到一个nulljavax.mail.AuthenticationFailedException?

Email 为什么我得到一个nulljavax.mail.AuthenticationFailedException?,email,exception,authentication,jakarta-mail,Email,Exception,Authentication,Jakarta Mail,我正在制作一个自动发送电子邮件的web应用程序,所以我使用javamail。我需要使用我公司的SMPT,无论我做什么,我都会得到一个nulljavax.mail.AuthenticationFailedException。这是我第一次使用它,我真的很沮丧,因为我已经尝试了大量的解决方案,但我仍然不能找出什么是错的。我用gmail做了一个测试,它成功了,但到目前为止没有任何帮助。这是我的密码: 更新:我已经对代码进行了更改,并按照建议删除了验证器 final String usernam

我正在制作一个自动发送电子邮件的web应用程序,所以我使用javamail。我需要使用我公司的SMPT,无论我做什么,我都会得到一个nulljavax.mail.AuthenticationFailedException。这是我第一次使用它,我真的很沮丧,因为我已经尝试了大量的解决方案,但我仍然不能找出什么是错的。我用gmail做了一个测试,它成功了,但到目前为止没有任何帮助。这是我的密码:

更新:我已经对代码进行了更改,并按照建议删除了验证器

     final String username = "dva.clamadrid@grupoautofin.com";
            final String password = "Leprechaun01";

            Properties props = new Properties();


            props.put("mail.transport.protocol", "smtp");

            props.put("mail.smtp.auth", "true");



            Session session = Session.getInstance(props);



            try {
                session.setDebug(true);
                Message message = new MimeMessage(session);
                message.setFrom(new InternetAddress("dva.clamadrid@grupoautofin.com"));
                message.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse("dva.clamadrid@grupoautofin.com"));
                message.setRecipients(Message.RecipientType.CC,
                        InternetAddress.parse(Copy));
                message.setSubject("Testing Subject");
                message.setText("Dear Mail Crawler,"
                    + "\n\n No spam to my email, please!");

                Transport transport = session.getTransport("smtp");
                transport.connect("SMTP.grupoautofin.com", 25, username, password);
                transport.sendMessage(message, message.getAllRecipients());
                transport.close();

                Log.i("Estás enviando: ",""+message.toString());

                System.out.println("Done");

            }catch(AuthenticationFailedException e) {
                    Log.e("ERROR DE AUTENTIFICACION: ",""+e.getMessage()+e);
                    e.printStackTrace();
                 bandera = false;

            } catch (MessagingException e) {
                bandera=false;
                Log.e("ERROR ENVIANDO: ",""+e.getMessage()+e);

                e.printStackTrace();

                //throw new RuntimeException(e);
            }
另外,我的错误日志,现在包含调试消息:

10-13 15:56:13.504: I/System.out(802): DEBUG: setDebug: JavaMail version 1.4.1
10-13 15:56:13.544: I/System.out(802): DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc.,1.4.1]
10-13 15:56:13.544: I/System.out(802): DEBUG SMTP: useEhlo true, useAuth true
10-13 15:56:13.544: I/System.out(802): DEBUG SMTP: trying to connect to host "SMTP.grupoautofin.com", port 25, isSSL false
10-13 15:56:13.835: I/System.out(802): 220 mtysmtp01.mexico.hosting.triara SMTP Server 01 is ready. Mon, 13 Oct 2014 14:56:13 -0500 
10-13 15:56:13.845: I/System.out(802): DEBUG SMTP: connected to host "SMTP.grupoautofin.com", port: 25
10-13 15:56:13.855: I/System.out(802): EHLO localhost
10-13 15:56:13.905: I/System.out(802): 250-mtysmtp01.mexico.hosting.triara Hello [189.203.255.42]
10-13 15:56:13.905: I/System.out(802): 250-TURN
10-13 15:56:13.905: I/System.out(802): 250-SIZE 27262976
10-13 15:56:13.915: I/System.out(802): 250-ETRN
10-13 15:56:13.915: I/System.out(802): 250-PIPELINING
10-13 15:56:13.915: I/System.out(802): 250-DSN
10-13 15:56:13.915: I/System.out(802): 250-ENHANCEDSTATUSCODES
10-13 15:56:13.915: I/System.out(802): 250-8bitmime
10-13 15:56:13.915: I/System.out(802): 250-BINARYMIME
10-13 15:56:13.915: I/System.out(802): 250-CHUNKING
10-13 15:56:13.915: I/System.out(802): 250-VRFY
10-13 15:56:13.915: I/System.out(802): 250-X-EXPS GSSAPI NTLM LOGIN
10-13 15:56:13.915: I/System.out(802): 250-X-EXPS=LOGIN
10-13 15:56:13.925: I/System.out(802): 250-AUTH GSSAPI NTLM LOGIN
10-13 15:56:13.925: I/System.out(802): 250-AUTH=LOGIN
10-13 15:56:13.925: I/System.out(802): 250-X-LINK2STATE
10-13 15:56:13.925: I/System.out(802): 250-XEXCH50
10-13 15:56:13.925: I/System.out(802): 250 OK
10-13 15:56:13.935: I/System.out(802): DEBUG SMTP: Found extension "TURN", arg ""
10-13 15:56:13.935: I/System.out(802): DEBUG SMTP: Found extension "SIZE", arg "27262976"
10-13 15:56:13.945: I/System.out(802): DEBUG SMTP: Found extension "ETRN", arg ""
10-13 15:56:13.945: I/System.out(802): DEBUG SMTP: Found extension "PIPELINING", arg ""
10-13 15:56:13.945: I/System.out(802): DEBUG SMTP: Found extension "DSN", arg ""
10-13 15:56:13.945: I/System.out(802): DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
10-13 15:56:13.955: I/System.out(802): DEBUG SMTP: Found extension "8bitmime", arg ""
10-13 15:56:13.955: I/System.out(802): DEBUG SMTP: Found extension "BINARYMIME", arg ""
10-13 15:56:13.955: I/System.out(802): DEBUG SMTP: Found extension "CHUNKING", arg ""
10-13 15:56:13.965: I/System.out(802): DEBUG SMTP: Found extension "VRFY", arg ""
10-13 15:56:13.965: I/System.out(802): DEBUG SMTP: Found extension "X-EXPS", arg "GSSAPI NTLM LOGIN"
10-13 15:56:13.965: I/System.out(802): DEBUG SMTP: Found extension "X-EXPS=LOGIN", arg ""
10-13 15:56:13.975: I/System.out(802): DEBUG SMTP: Found extension "AUTH", arg "GSSAPI NTLM LOGIN"
10-13 15:56:13.975: I/System.out(802): DEBUG SMTP: Found extension "AUTH=LOGIN", arg ""
10-13 15:56:13.985: I/System.out(802): DEBUG SMTP: Found extension "X-LINK2STATE", arg ""
10-13 15:56:14.004: I/System.out(802): DEBUG SMTP: Found extension "XEXCH50", arg ""
10-13 15:56:14.004: I/System.out(802): DEBUG SMTP: Found extension "OK", arg ""
10-13 15:56:14.015: I/System.out(802): DEBUG SMTP: Attempt to authenticate
10-13 15:56:14.025: I/System.out(802): AUTH LOGIN
10-13 15:56:14.075: I/System.out(802): 334 VXNlcm5hbWU6
10-13 15:56:14.085: I/System.out(802): ZHZhLmNsYW1hZHJpZEBncnVwb2F1dG9maW4uY29t
10-13 15:56:14.135: I/System.out(802): 334 UGFzc3dvcmQ6
10-13 15:56:14.135: I/System.out(802): TGVwcmVjaGF1bjAx
10-13 15:56:14.416: I/System.out(802): 535 5.7.3 Authentication unsuccessful.
10-13 15:56:14.424: E/ERROR DE AUTENTIFICACION:(802): nulljavax.mail.AuthenticationFailedException
还是同样的错误,我还做错了什么?提前谢谢。

首先,摆脱它

第二,如果要显式调用connect方法,则不需要host、port或auth属性,这样也可以摆脱它们

您已经做了一些事情来验证您传递的用户名和密码是否正确,对吗


打开该选项,调试输出可能会提供更多有关出错原因的线索。您可能需要将“mail.debug.auth”属性设置为“true”,以查看完整的身份验证协议交换(其中将包括您的密码)以查看失败的详细信息。如果您仍然无法理解,请发布调试输出(没有身份验证交换)。

首先,您使用的是非常旧的JavaMail版本。因此,身份验证协议跟踪包含在调试输出中,任何人都可以对其进行解码以读取您的密码。请立即更改您的密码。第二,您以前不是设置了mail.smtp.starttls.enable属性吗?这似乎已经过去了。在进行身份验证之前,您可能需要切换到SSL/TLS,以便服务器愿意接受您的密码。我的两个问题都已解决,谢谢您的输入。