Ich verwende den folgenden Code zum Senden von E -Mails mit Java < /p>
function send(){
String host1 = "domainname";
String to = "[email protected]";
String from="[email protected]";
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 = "[email protected]";
String password = "**********";
authentication = new PasswordAuthentication(username, password);
}
protected PasswordAuthentication getPasswordAuthentication() {
return authentication;
}
}
< /code>
Was gut funktioniert. Aber jetzt muss ich die aus der Adresse "[email protected]" ändern und ich muss E -Mails mit denselben Authentifizierungsdetails wie zuvor senden.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>
Ist dies möglich, um E -Mails mit derselben Authentifizierung zu senden und sich von der Adresse zu unterscheiden ..... < /p>
Kann mir jemand helfen, das Problem zu finden ..... < /p>
SMTPADDressFailedException: 550-Verlust ist fehlgeschlagen ⇐ Java
-
- Similar Topics
- Replies
- Views
- Last post