JAVAMAIL 535 5.7.8认证失败(Javamail 535 5.7.8 authenti

2019-09-28 09:48发布

我使用JavaMail API来发送邮件。

下面的代码已经工作了5个月左右:

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

但现在我得到这个错误:

535 5.7.8 Error: authentication failed: authentication failure

我试图用

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

与VALUE = “LOGIN” 或价值= “普通” 或价值= “DIGEST-MD5” 或价值= “CRAM-MD5”,但没有奏效。 我试图通过web邮件发送电子邮件和它的工作,所以我的帐户未关闭,我的凭据是正确的。

这是调试跟踪:

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

你有什么想法?

Answer 1:

尝试改变作为Session.getDefaultInstance到Session.getInstance。

如果没有帮助,包括更多显示失败的调试输出。



文章来源: Javamail 535 5.7.8 authentication failed