[JavaMail] problème d'envoi de courrier avec SMTP
Bonjour à tous,
j'utilise actuellement JAVAMAIL pour envoyer mes mails, mais j'ai une erreur à l'envoi. Voici le code que j'utilise :
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 31 32
|
public void postMail(String to, String subject, String message , String from) throws MessagingException {
boolean debug = true;
//On renseigne les propriétés SMTP
Properties props = new Properties();
props.put("mail.smtp.host", config.getSmtpHostName());
if (config.getSmtpAuthUser() != "") {
props.put("mail.smtp.auth", "true");
} else {
props.put("mail.smtp.auth", "false");}
//props.put("mail.smtp.auth", "true");
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, auth);
session.setDebug(debug);
//Création du mail
Message msg = new MimeMessage(session);
//Adresse source et adresse destination...
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress addressTo = new InternetAddress(to);
msg.setRecipient(Message.RecipientType.TO, addressTo);
//On règle le sujet et le corps du message
msg.setSubject(subject);
msg.setContent(message, "text/html");
Transport.send(msg);
} |
Et voici l'erreur que je reçois :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
DEBUG SMTP Found extension "PIPELINING", arg ""
DEBUG SMTP Found extension "SIZE", arg "10485760"
DEBUG SMTP Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP Found extension "AUTH=PLAIN", arg "LOGIN"
DEBUG SMTP Found extension "8BITMIME", arg ""
DEBUG SMTP: use8bit false
DEBUG SMTP SENT: MAIL FROM:<mymail@hotmail.com>
DEBUG SMTP RCVD: 250 Ok
DEBUG SMTP SENT: RCPT TO:<mymail@hotmail.com>
DEBUG SMTP RCVD: 554 <mymail@hotmail.com>: Recipient address rejected: Missing Authentication
Invalid Addresses
<a href="mailto:mymail@hotmail.com">mymail@hotmail.com</a>
DEBUG SMTPTransport: Sending failed because of invalid destination addresses
DEBUG SMTP SENT: RSET
DEBUG SMTP RCVD: 250 Ok
DEBUG SMTP SENT: QUIT |
Pourtant mymail@hotmail.com est une adresse valide, j'ai essayé avec d'autres et le problème reste le même. Enfin, concernant le Missing Authentication il ne devrait pas y avoir de probleme puisque mon provider (Orange) n'en demande pas.
Si vous avez la moindre piste ou suggestion je suis grandement preneur, j'ai fouillé sur le forum mais je n'ai rien trouvé pour l'instant :?
Merci d'avance!
Gilles