Javamail 535 5.7.8身份验证失败 [英] Javamail 535 5.7.8 authentication failed

查看:703
本文介绍了Javamail 535 5.7.8身份验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用javamail api发送邮件.

I'm using javamail api to send mails.

以下代码已经运行了大约5个月:

The following code has been working for about 5 months:

public static void sendMail(String dest, String oggetto, String testoEmail, String[] filePath) throws MessagingException{
    String sender2="mymail";
    String passSender2="mypass";
    String smpt2="smpt server";
    String port2="25";
    Properties props = new Properties();
    props.put("mail.smtp.port", port2);  //imposta la porta
    props.put("mail.smtp.host", smpt2);
    props.put("mail.smtps.auth", "true");
    props.put("mail.debug", "true");
    props.put("mail.smtp.starttls.enable","true");  //imposta la connessione cifrata





    Session session = Session.getDefaultInstance(props, null);

    MimeMessage message = getMessage(filePath, oggetto, session, testoEmail);


    InternetAddress fromAddress = new InternetAddress(sender2);
    InternetAddress toAddress = new InternetAddress(dest);
    message.setFrom(fromAddress);
    message.setRecipient(Message.RecipientType.TO, toAddress);
    Transport transport = session.getTransport("smtp");
    transport.connect(smpt2, 25, sender2, passSender2);

    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
}

但是现在我得到了这个错误:

But now i get this error:

535 5.7.8 Error: authentication failed: authentication failure

我尝试使用

props.put("mail.smtp.auth.mechanisms", "VALUE" );

使用Value ="LOGIN"或value ="PLAIN"或value ="DIGEST-MD5"或value ="CRAM-MD5",但没有任何效果. 我试图通过网络邮件发送电子邮件,但该电子邮件仍然有效,因此我的帐户未关闭,并且我的凭据正确.

with Value="LOGIN" or value="PLAIN" or value="DIGEST-MD5" or value="CRAM-MD5" but nothing worked. I tried to send an email through the webmail and it worked, so my account is not closed, and my credentials are right.

这是调试跟踪:

DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "smtserver", port 25, isSSL false
220 smtserver ESMTP Postfix
DEBUG SMTP: connected to host "smtserver", port: 25

EHLO MYPC
250-smtserver
250-PIPELINING
250-SIZE 102400000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "SIZE", arg "102400000"
DEBUG SMTP: Found extension "VRFY", arg ""
DEBUG SMTP: Found extension "ETRN", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
AUTH LOGIN
334 VevergrgEDFEF6
SC,OPVKDVEPOVKPOKPKPPK
334 dvelvrevrevr
WEFERFREFREFD
535 5.7.8 Error: authentication failed: authentication failure

您有什么主意吗?

推荐答案

尝试将Session.getDefaultInstance更改为Session.getInstance.

Try changing Session.getDefaultInstance to Session.getInstance.

如果这样做没有帮助,请提供更多显示故障的调试输出.

If that doesn't help, include more of the debug output showing the failure.

这篇关于Javamail 535 5.7.8身份验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆