javax.mail.AuthenticationFailedException:535 5.7.3身份验证失败 [英] javax.mail.AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful

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

问题描述

我正在使用SMTP错误发送电子邮件。我无法获得身份验证。用户名和密码正确。我在做错什么吗?

I am sending e email using an SMTP error . I am getting Authentication unsuccessful. The username and password are correct. Am I doing something wrong.

错误日志是

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class EmailSender{

    public static void main(String args[]) {
        String to = "ssss@xxx.om";            // sender email
        String from = "dddd@xxx.com";       // receiver email
        String host = "dkdkdd.xxx.com";                   // mail server host

        String login="dkkdkd";
        String pass="dkkdkd";
       Properties properties = System.getProperties();
        properties.setProperty("mail.smtp.host", host);
        properties.setProperty("mail.smtp.user", login);
        properties.setProperty("mail.smtp.password", pass);
        properties.setProperty("mail.smtps.ssl.enable", "true");
       // properties.setProperty("mail.smtp.auth", "true"); 

        Session session = Session.getDefaultInstance(properties); // default session

        try {
            MimeMessage message = new MimeMessage(session);        // email message
            message.setFrom(new InternetAddress(from));                    // setting header fields
            message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
            message.setSubject("Test Mail from Java Program"); // subject line

            // actual mail body
            message.setText("You can send mail from Java program by using");

            // Send message
            Transport transport = session.getTransport("smtp");
            transport.connect(host, login, pass);
            Transport.send(message);
            System.out.println("Email Sent successfully....");
        } catch (MessagingException mex) {
            mex.printStackTrace();
        }
    }

}

错误是

调试SMTP:AUTH NTLM失败
线程 main中的异常javax.mail.AuthenticationFailedException:535 5.7.3身份验证失败

DEBUG SMTP: AUTH NTLM failed Exception in thread "main" javax.mail.AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful

at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:826)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:761)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:685)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)


推荐答案

有相同的问题。这是您收到的MS Exchange错误。您可能不被允许使用您的电子邮件通过中继发送电子邮件。 Exchange服务器的管理员需要授予这样做的权限。

Had the same issue. It's an MS Exchange error that you receive. You are probably not allowed to use your email to send an email via a relay. The administrator of the Exchange server needs to give the rights to do that.

它与Java方面的配置问题无关。

It has nothing to do with a configuration problem on the Java side.

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

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