Java mail authentification
Bonjour,
pour me connecter a un smtp sans authentification pas de probleme.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
/**
* SimpleAuthenticator is used to do simple authentication when the SMTP
* server requires it.
*/
private static class SMTPAuthenticator extends javax.mail.Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
String username = SMTP_AUTH_USER;
String password = SMTP_AUTH_PWD;
return new PasswordAuthentication(username, password);
}
}
boolean debug = true;
// Set the host smtp address
Properties props = new Properties();
props.put("mail.smtp.host", smtp);
props.put("mail.smtp.port", "3535");
props.put("mail.smtp.auth", "true");
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getInstance(props, auth);
// Session session = Session.getDefaultInstance(props,null);
session.setDebug(debug);
Transport tr = session.getTransport("smtp");
tr.connect(smtp,SMTP_AUTH_USER , SMTP_AUTH_PWD);
tr.sendMessage(msg, adress);
//tr.s
Transport.send(msg); |
Voila quand je fais "tr.connect" ou Transport.send(msg);
j ai en debug la trace suivantes :
DEBUG SMTP SENT: DATA
DEBUG SMTP RCVD: 354 End your message with a period.
DEBUG SMTP SENT:
.
DEBUG SMTP RCVD: 554 Message refused.
DEBUG SMTP SENT: QUIT
Si quelqu un connait le smtp est celui de godaddy.com
smtpout.secureserver.net sur le port 3535.
J utilise un compte email avec son password pour m authentifier.