Java 身份验证失败异常

Java 身份验证失败异常,java,servlets,jakarta-mail,Java,Servlets,Jakarta Mail,这是我的代码:由于隐私问题,不会向您显示密码字段,但我已在代码中输入了真实密码 public static void send(String to, String subject, String msg) { final String user = "guru_190693@rediffmail.com";//change accordingly final String pass = "*******"; Properties props = new Proper

这是我的代码:由于隐私问题,不会向您显示密码字段,但我已在代码中输入了真实密码

public static void send(String to, String subject, String msg) {

    final String user = "guru_190693@rediffmail.com";//change accordingly
    final String pass = "*******";


    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", "smtp.live.com");

    Session session;
    session = Session.getInstance(props,
    new javax.mail.Authenticator() {
        @Override
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(user, pass);
        }
    });

    try {
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(user));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSubject(subject);


        Multipart multipart = new MimeMultipart();


        BodyPart messageBodyPart = new MimeBodyPart();

        messageBodyPart.setText("This is message body");


        multipart.addBodyPart(messageBodyPart);


        messageBodyPart = new MimeBodyPart();
        String filename = "C:\\Users\\Harbir\\Pictures\\Photo0471.jpg";
        DataSource source = new FileDataSource(filename);
        messageBodyPart.setDataHandler(new DataHandler(source));
        messageBodyPart.setFileName(filename);
        multipart.addBodyPart(messageBodyPart);


        message.setContent(multipart);

        Transport.send(message);

        System.out.println("Done");

    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }

}
}


它捕获了一个异常身份验证失败535.0.0。我知道有类似的帖子,但我没有发现任何有用的东西。这就是我再次发布它的原因。帮助更改这部分代码

Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.live.com");


要想让它发挥作用,你需要升级你的
guru_190693@rediffmail.com
转到rediff mail pro帐户。

您正在
live.com
服务器上使用
rediff mail
帐户凭据。因此出现身份验证失败错误。我应该使用windows live帐户吗xyz@windows.live.com?您必须使用smtp服务器可接受的帐户
smtp.live.com
。我不知道
live.com
的账户是什么样子。我没有账户。如果用户对
pro
账户不感兴趣,那怎么办呢。是的,没错。。。同样的问题:/只要更改您使用的电子邮件提供商即可。谷歌雅虎等提供免费服务。你可以使用465端口而不是587端口。465是对所有服务器开放的通用端口。只需将write smtp.rediffmail.com更改为您的主机。其余的代码是完美的!
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.rediffmailpro.com");
props.put("mail.smtp.port", "587");