简体   繁体   English

SMTPAddressFailedException: 550-验证失败

[英]SMTPAddressFailedException: 550-Verification failed

i am using following code for sending emails using java我正在使用以下代码使用 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;
    }
}

which works fine.But now i need to change the from address "someother@domain.com" and i have to send mails using the same authentication details as before.效果很好。但是现在我需要更改发件人地址“someother@domain.com”,并且我必须使用与以前相同的身份验证详细信息来发送邮件。 if i just change my from address with the same authentication am getting the following error:如果我只是用相同的身份验证更改我的发件人地址,我会收到以下错误:

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

is this possible to send mails with same authentication and different from address.....这是否可以发送具有相同身份验证但地址不同的邮件.....

Can any one help me in finding the issue.....任何人都可以帮助我找到问题......

What I suspect is that there is some configuration or policy which prevents the outgoing mails where the from address is not registered with it.我怀疑是有一些配置或策略from发件人地址未注册的外发邮件。 If you problem is to configure an address where the users can reply to (and which should be different from the one you are authenticating), then there is a reply-to header which you can set.如果您的问题是配置一个用户可以回复的地址(并且应该与您正在验证的地址不同),那么您可以设置一个reply-to标头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM