Код: Выделить всё
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;
}
}
если я просто изменю свой адрес отправителя с той же аутентификацией, я получаю следующую ошибку:
Код: Выделить всё
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
Может ли кто-нибудь помочь мне найти проблему.....
Подробнее здесь: https://stackoverflow.com/questions/112 ... ion-failed
Мобильная версия