Problème pour envoyer un mail (JavaMail)

Problème pour envoyer un mail (JavaMail) - Java - Programmation

Marsh Posté le 07-05-2006 à 19:02:16    

Bonsoir.
 
Voilà je suis actuellement en Chine et donc connecté à un provider chinois. J'ai fait un ptit programme qui envoie juste un mail à l'adresse souhaité. Je veux utiliser le serveur smtp de free (ou même de wanadoo) mais il me fait une erreur que je ne comprend pas (mon username est correcte et mon mot de passe aussi ... quelqu'un peut-il m'expliquer où est le problème s'il vous plaît car là je ne vois pas.
 
Ma classe Email

Code :
  1. package test;
  2. import java.util.*;
  3. import javax.mail.internet.*;
  4. import javax.mail.*;
  5. public class Email{
  6. private String messageTo, messageFrom, subject;
  7.         public boolean mail(String messageTo, String messageFrom, String subject)
  8. {
  9.  this.messageTo = messageTo;
  10.  this.messageFrom = messageFrom;
  11.  this.subject = subject;
  12.  boolean result = false;
  13. try{
  14.  Properties props = new Properties();
  15.  props.put("mail.smtp.host", "smtp.wanadoo.fr" );
  16.  //props.put("mail.smtp.auth", mon_password);
  17.  Session session;
  18.  session = Session.getDefaultInstance(props, null);
  19.  session.setDebug(true);
  20.  InternetAddress free = new InternetAddress("smtp.wanadoo.fr" );
  21.  Transport transport = session.getTransport(free);
  22.  transport.connect("smtp.wanadoo.fr", "mon_username", "mon_password" );
  23.  Message message = new MimeMessage(session);
  24.  InternetAddress addressFrom = new InternetAddress(messageFrom);
  25.  message.setFrom(addressFrom);
  26.  InternetAddress addressTo = new InternetAddress(messageTo);
  27.  message.addRecipient(Message.RecipientType.TO, addressTo);
  28.  message.setSubject(subject);
  29.  message.setText("Juste pour tester le mail." );
  30.  //String texte = "<H1>test</H1>";
  31.  //message.setContent(texte, "text/html" );
  32.  Transport.send(message);
  33.  } catch (AddressException e) {
  34.   e.printStackTrace();
  35.  } catch (MessagingException e) {
  36.          e.printStackTrace();
  37.  }
  38.  return result = true;
  39. }
  40. }


 
Ma classe Send

Code :
  1. package test;
  2. import test.Email;
  3. public class Send {
  4. public static void main(String[] args) {
  5.  Email email = new Email();
  6.  email.mail("email_destinataire", "email_expediteur", "test encore" );
  7. }
  8. }


 
Voici ce que me sort le Debug :

Code :
  1. DEBUG: setDebug: JavaMail version 1.4ea
  2. DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
  3. DEBUG SMTP: useEhlo true, useAuth false
  4. DEBUG SMTP: trying to connect to host "smtp.wanadoo.fr", port 25, isSSL false
  5. 220 mwinf0109.wanadoo.fr ESMTP **************************
  6. DEBUG SMTP: connected to host "smtp.wanadoo.fr", port: 25
  7. EHLO nico
  8. 250-mwinf0109.wanadoo.fr
  9. 250-PIPELINING
  10. 250-SIZE 20971520
  11. 250 8BITMIME
  12. DEBUG SMTP: Found extension "PIPELINING", arg ""
  13. DEBUG SMTP: Found extension "SIZE", arg "20971520"
  14. DEBUG SMTP: Found extension "8BITMIME", arg ""
  15. DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
  16. DEBUG SMTP: useEhlo true, useAuth false
  17. DEBUG SMTP: trying to connect to host "smtp.wanadoo.fr", port 25, isSSL false
  18. 220 mwinf0109.wanadoo.fr ESMTP **************************
  19. DEBUG SMTP: connected to host "smtp.wanadoo.fr", port: 25
  20. EHLO nico
  21. 250-mwinf0109.wanadoo.fr
  22. 250-PIPELINING
  23. 250-SIZE 20971520
  24. 250 8BITMIME
  25. DEBUG SMTP: Found extension "PIPELINING", arg ""
  26. DEBUG SMTP: Found extension "SIZE", arg "20971520"
  27. DEBUG SMTP: Found extension "8BITMIME", arg ""
  28. DEBUG SMTP: use8bit false
  29. MAIL FROM:<email_exp>
  30. 250 Ok
  31. RCPT TO:<email_dest>
  32. 554 <email_dest>: Relay access denied
  33. DEBUG SMTP: Invalid Addresses
  34. DEBUG SMTP:   email_dest
  35. DEBUG SMTP: Sending failed because of invalid destination addresses
  36. RSET
  37. 250 Ok
  38. javax.mail.SendFailedException: Invalid Addresses
  39. at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1161)
  40. at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:554)
  41. at javax.mail.Transport.send0(Transport.java:169)
  42. at javax.mail.Transport.send(Transport.java:98)
  43. at test.Email.mail(Email.java:54)
  44. at test.Send.main(Send.java:16)
  45. Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 554 <email_dest>: Relay access denied
  46. at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1059)
  47. ... 5 more
  48. QUIT
  49. 221 Bye
  50. javax.mail.SendFailedException: Invalid Addresses
  51. at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1161)
  52. at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:554)
  53. at javax.mail.Transport.send0(Transport.java:169)
  54. at javax.mail.Transport.send(Transport.java:98)
  55. at test.Email.mail(Email.java:54)
  56. at test.Send.main(Send.java:16)
  57. Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 554 <email_dest>: Relay access denied
  58. at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1059)
  59. ... 5 more


 
Alors là apparement il me dit que le mail de l'expéditeur n'est pas bon (je ne vois pas pourquoi).  
 
Une idée ?

Reply

Marsh Posté le 07-05-2006 à 19:02:16   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed