SMTPAddressFailedException:550-Verification失败

时间:2012-06-26 08:00:23

标签: java email smtp

我正在使用以下代码使用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

这可以发送具有相同身份验证且与地址不同的邮件.....

任何人都可以帮我找到问题.....

1 个答案:

答案 0 :(得分:0)

我怀疑有一些配置或策略会阻止from地址未注册的外发邮件。如果您遇到问题是配置用户可以回复的地址(以及与您要进行身份验证的地址不同),那么您可以设置reply-to标题。