nickiller | 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 :
- package test;
- import java.util.*;
- import javax.mail.internet.*;
- import javax.mail.*;
- public class Email{
- private String messageTo, messageFrom, subject;
- public boolean mail(String messageTo, String messageFrom, String subject)
- {
- this.messageTo = messageTo;
- this.messageFrom = messageFrom;
- this.subject = subject;
- boolean result = false;
- try{
- Properties props = new Properties();
- props.put("mail.smtp.host", "smtp.wanadoo.fr" );
- //props.put("mail.smtp.auth", mon_password);
- Session session;
- session = Session.getDefaultInstance(props, null);
- session.setDebug(true);
- InternetAddress free = new InternetAddress("smtp.wanadoo.fr" );
- Transport transport = session.getTransport(free);
- transport.connect("smtp.wanadoo.fr", "mon_username", "mon_password" );
- Message message = new MimeMessage(session);
- InternetAddress addressFrom = new InternetAddress(messageFrom);
- message.setFrom(addressFrom);
- InternetAddress addressTo = new InternetAddress(messageTo);
- message.addRecipient(Message.RecipientType.TO, addressTo);
- message.setSubject(subject);
- message.setText("Juste pour tester le mail." );
- //String texte = "<H1>test</H1>";
- //message.setContent(texte, "text/html" );
- Transport.send(message);
- } catch (AddressException e) {
- e.printStackTrace();
- } catch (MessagingException e) {
- e.printStackTrace();
- }
- return result = true;
- }
- }
|
Ma classe Send
Code :
- package test;
- import test.Email;
- public class Send {
- public static void main(String[] args) {
- Email email = new Email();
- email.mail("email_destinataire", "email_expediteur", "test encore" );
- }
- }
|
Voici ce que me sort le Debug :
Code :
- DEBUG: setDebug: JavaMail version 1.4ea
- DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
- DEBUG SMTP: useEhlo true, useAuth false
- DEBUG SMTP: trying to connect to host "smtp.wanadoo.fr", port 25, isSSL false
- 220 mwinf0109.wanadoo.fr ESMTP **************************
- DEBUG SMTP: connected to host "smtp.wanadoo.fr", port: 25
- EHLO nico
- 250-mwinf0109.wanadoo.fr
- 250-PIPELINING
- 250-SIZE 20971520
- 250 8BITMIME
- DEBUG SMTP: Found extension "PIPELINING", arg ""
- DEBUG SMTP: Found extension "SIZE", arg "20971520"
- DEBUG SMTP: Found extension "8BITMIME", arg ""
- DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
- DEBUG SMTP: useEhlo true, useAuth false
- DEBUG SMTP: trying to connect to host "smtp.wanadoo.fr", port 25, isSSL false
- 220 mwinf0109.wanadoo.fr ESMTP **************************
- DEBUG SMTP: connected to host "smtp.wanadoo.fr", port: 25
- EHLO nico
- 250-mwinf0109.wanadoo.fr
- 250-PIPELINING
- 250-SIZE 20971520
- 250 8BITMIME
- DEBUG SMTP: Found extension "PIPELINING", arg ""
- DEBUG SMTP: Found extension "SIZE", arg "20971520"
- DEBUG SMTP: Found extension "8BITMIME", arg ""
- DEBUG SMTP: use8bit false
- MAIL FROM:<email_exp>
- 250 Ok
- RCPT TO:<email_dest>
- 554 <email_dest>: Relay access denied
- DEBUG SMTP: Invalid Addresses
- DEBUG SMTP: email_dest
- DEBUG SMTP: Sending failed because of invalid destination addresses
- RSET
- 250 Ok
- javax.mail.SendFailedException: Invalid Addresses
- at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1161)
- at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:554)
- at javax.mail.Transport.send0(Transport.java:169)
- at javax.mail.Transport.send(Transport.java:98)
- at test.Email.mail(Email.java:54)
- at test.Send.main(Send.java:16)
- Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 554 <email_dest>: Relay access denied
- at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1059)
- ... 5 more
- QUIT
- 221 Bye
- javax.mail.SendFailedException: Invalid Addresses
- at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1161)
- at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:554)
- at javax.mail.Transport.send0(Transport.java:169)
- at javax.mail.Transport.send(Transport.java:98)
- at test.Email.mail(Email.java:54)
- at test.Send.main(Send.java:16)
- Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 554 <email_dest>: Relay access denied
- at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1059)
- ... 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 ? |