gpt4 book ai didi

java - 无法从java程序: Unable to relay for abc@wipro. com发送电子邮件

转载 作者:行者123 更新时间:2023-12-01 11:48:24 26 4
gpt4 key购买 nike

我正在尝试使用这篇文章 Java Point Post 使用 java 程序发送电子邮件。

import java.util.Properties;  
import javax.mail.*;
import javax.mail.internet.*;

public class SendMailBySite {
public static void main(String[] args) {

String host="IPADDRESS";
final String user="abc@wipro.com";//change accordingly
final String password="xxx";//change accordingly

String to="abc@wipro.com";//change accordingly

//Get the session object
Properties props = new Properties();
props.put("mail.smtp.host",host);
props.put("mail.smtp.auth", "true");

Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user,password);
}
});

//Compose the message
try {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(user));
message.addRecipient(Message.RecipientType.TO,new InternetAddress

(to));
message.setSubject("javatpoint");
message.setText("This is simple program of sending email using

JavaMail API");

//send the message
Transport.send(message);

System.out.println("message sent successfully...");

} catch (MessagingException e) {e.printStackTrace();}
}
}

我已正确输入 IpAddress,并且我的邮件 ID 和密码均正确。但是当我尝试运行这个程序时遇到一些异常。

java SendEmail
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 550 5.7.1 Unable to relay for abc@wipro.com

at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at SendEmail.main(SendEmail.java:27)

请帮忙。提前致谢。

最佳答案

javax.mail.SendFailedException:550无法中继我的地址

This is not a JavaMail problem. This is an error reply from your SMTP mail server. It indicates that your mail server is not configured to allow you to send mail through it

Source

尝试更改 smtp 主机(例如 google)。另请检查 send email via google SMTP .

关于java - 无法从java程序: Unable to relay for abc@wipro. com发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28957056/

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