【问题标题】:Javamail 535 5.7.8 authentication failedJavamail 535 5.7.8 认证失败
【发布时间】:2013-12-19 22:26:23
【问题描述】:

我正在使用 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" 或 value="PLAIN" 或 value="DIGEST-MD5" 或 value="CRAM-MD5" 但没有任何效果。 我尝试通过 webmail 发送一封电子邮件,它成功了,所以我的帐户没有关闭,我的凭据是正确的。

这是调试跟踪:

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

你有什么想法吗?

【问题讨论】:

    标签: java smtp jakarta-mail


    【解决方案1】:

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

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

    【讨论】:

    • 它没有帮助,但我发布了调试跟踪感谢您的回答。
    • 几点... 1)您似乎使用的是旧版本的JavaMail,您可能需要升级; 2) 立即修改密码,AUTH LOGIN 后的base64 编码就是你的用户名和密码,任何人都可以解码; 3)您启用了 starttls 但您的服务器不支持它; 4) 以上所有内容都表明您的服务器认为您提供的用户名或密码不正确,请尝试发送不带@hostname 部分的用户名。
    猜你喜欢
    • 2012-03-14
    • 2017-11-29
    • 2011-10-11
    • 2018-02-08
    • 1970-01-01
    • 2011-05-19
    • 2021-07-30
    • 2013-08-07
    • 1970-01-01
    相关资源
    最近更新 更多