我正在使用下面的代码通过java发送电子邮件
function send(){
String host1 = "domainname";
String to = "test@domain.com";
String from="dontreply@domain.com";
String subject = "test mail";
String messageText = "test content";
boolean sessionDebug = false;
Properties props = System.getProperties();
props.put("mail.host", host1);
props.put("mail.transport.protocol", "smtp");
Authenticator authenticator = new Authenticator();
Session mailSession = Session.getInstance(props, authenticator);
mailSession.setDebug(sessionDebug);
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
//msg.setSentDate(new Date());
msg.setContent(messageText,"text/html");
Transport.send(msg);
}
private class Authenticator extends javax.mail.Authenticator implements java.io.Serializable {
private PasswordAuthentication authentication;
public Authenticator() {
String username = "support@domain.com";
String password = "**********";
authentication = new PasswordAuthentication(username, password);
}
protected PasswordAuthentication getPasswordAuthentication() {
return authentication;
}
}现在我需要更改发件人地址"someother@domain.com“,并且我必须使用与以前相同的身份验证详细信息发送邮件。如果我只是使用相同的身份验证更改发件人地址,则会收到以下错误:
exceptionjavax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550-Verification failed for <someother@domain.com>
550-No Such User Here"
550 Sender verify failed是否可以使用相同的身份验证和不同的地址发送邮件.....
有没有人可以帮我找出这个问题……
发布于 2012-06-26 17:28:05
我怀疑是某些配置或策略阻止了from地址未向其注册的外发邮件。如果您的问题是配置用户可以回复的地址(并且该地址应该与您正在进行身份验证的地址不同),那么您可以设置一个reply-to标头。
https://stackoverflow.com/questions/11203050
复制相似问题