gpt4 book ai didi

java - 认证失败异常

转载 作者:行者123 更新时间:2023-12-01 12:59:29 31 4
gpt4 key购买 nike

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

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 5.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");

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");

要实现此功能,您需要将 guru_190693@rediffmail.com 升级为 rediff mail pro 帐户。

关于java - 认证失败异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23629075/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com