Bonjour,

quand j'essaye d'envoyer des mails j'ai l'erreur suivante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
Exception in thread "main" 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 utils.EnvoiMail.postMail(EnvoiMail.java:118)
     at utils.EnvoiMail.sendMailToRecruteur(EnvoiMail.java:183)
     at utils.EnvoiMail.main(EnvoiMail.java:69)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 553 sorry, that domain isn't in my list of allowed rcpthosts; no valid cert for gatewaying (#5.7.1)
 
     at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1012)
     ... 4 more
ma propre adresse mail est du genre : xxx@mondomaine.com

quand j'envois un mail à une adresse dont le domaine est "mondomaine.com" ca marche mais dès que c'est un autre domaine j'ai l'erreur indiquée dessus.

voici mon ptit programme d'envoie de mail

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
public void postMail(String recipients[], String subject,
                    String from, String nom, String prenom, String mail, String mdp, boolean candidat, String type) throws MessagingException {
               boolean debug = false;
               //Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
 
               //Set the host smtp address
               Properties props = new Properties();
               props.put("mail.transport.protocol", "smtp");
               props.put("mail.smtp.starttls.enable","true");
               props.put("mail.smtp.host", SMTP_HOST_NAME);
               props.put("mail.smtp.auth", "true");
               props.put("mail.smtp.user", SMTP_AUTH_USER);
               props.put("mail.smtp.password", SMTP_AUTH_PWD);
 
               Authenticator auth = new PopupAuthenticator(SMTP_AUTH_USER,SMTP_AUTH_PWD);
               Session session = Session.getInstance(props,auth);
 
               session.setDebug(debug);
 
               // create a message
               Message msg = new MimeMessage(session);
 
               // set the from and to address
               InternetAddress addressFrom = new InternetAddress(from);
               msg.setFrom(addressFrom);
 
               InternetAddress[] addressTo = new InternetAddress[recipients.length];
               for (int i = 0; i < recipients.length; i++) {
                    addressTo[i] = new InternetAddress(recipients[i]);
               }
               msg.setRecipients(Message.RecipientType.TO, addressTo);
 
               // Setting the Subject and Content Type
               msg.setSubject(subject);
               msg.setSentDate(new Date());
               //msg.setContent(message, "text/plain");
               msg.setContent("test", "text/html");
 
 
               SMTPTransport transport = (SMTPTransport)session.getTransport("smtp");
               transport.connect(SMTP_HOST_NAME,SMTP_AUTH_USER, SMTP_AUTH_PWD);
               transport.sendMessage(msg, msg.getAllRecipients());
 
               transport.close();
 
          }
Merci d'avance pour votre aide