Я использую следующий код для отправки электронных писем с помощью Java < /p>
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;
}
}
< /code>
, который работает нормально. Но теперь мне нужно изменить адрес «someether@domain.com», и мне нужно отправлять почты, используя те же данные аутентификации, что и раньше.
Если я просто изменяю свой адрес с той же аутентификацией.exceptionjavax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550-Verification failed for
550-No Such User Here"
550 Sender verify failed
< /code>
можно ли отправлять почты с одинаковой аутентификацией и отличается от адреса ..... < /p>
может помочь мне в поиске проблемы ..... < /p>
Подробнее здесь: https://stackoverflow.com/questions/112 ... ion-failed