Bonjour,

je sais que ce problème à été posté mainte et mainte fois mais je n'ai pas réussis à régler le problème car chaque problème est différent.

pour ma part j'ai un soucis avec l'envoi de mail avec un serveur distant alors qu'il fonctionne très bien en local.

Voila mon message d'erreur :
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
Initialization of the properties file and the logger.
Application Properties: AEnercom-CollectInformation_application.properties
Environment Properties variable: AEnercom-CollectInformation_environment.properties
Log4j Properties variable: AEnercom-CollectInformation_log4j.properties
The Application Properties file name: /home/aenercom-test/software/java/CollectInformation/properties/AEnercomCollectInformation_application.properties
The Environmment Properties file name: /home/aenercom-test/software/java/CollectInformation/properties/AEnercomCollectInformation_environment_demo.properties
The log path :/home/aenercom-test/software/java/CollectInformation/properties/AEnercomCollectInformation_log4j_demo.properties
log4j:WARN No appenders could be found for logger (org.apache.commons.configuration.ConfigurationUtils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
login : aenercom
pass : 4En3rCOM45
DEBUG: JavaMail version 1.4.1
DEBUG: not loading file: /usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/javamail.providers
DEBUG: java.io.FileNotFoundException: /usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/javamail.providers (No such file or directory)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: not loading resource: /META-INF/javamail.default.providers
DEBUG: failed to load any providers, using defaults
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc.,1.4.1], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc.,1.4.1], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc.,1.4.1], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc.,1.4.1], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc.,1.4.1], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc.,1.4.1]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc.,1.4.1], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc.,1.4.1], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc.,1.4.1], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc.,1.4.1], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc.,1.4.1], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc.,1.4.1]}
DEBUG: not loading resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: not loading file: /usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/javamail.address.map
DEBUG: java.io.FileNotFoundException: /usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/javamail.address.map (No such file or directory)
DEBUG: failed to load address map, using defaults
DEBUG: setDebug: JavaMail version 1.4.1
Throwable main() : java.lang.NoClassDefFoundError: com/sun/mail/util/MessageRemovedIOException
!! The batch server is completed !!
Je précise que c par Exchange que le mail s'envoie.

et voila le code d'envoi :
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
 
 
smtpServer = mail.serveur.com
port = 143
user = test
password = test
 
 
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpServer);
props.put("mail.smtp.port", port);
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
 
Session session = Session.getInstance(props, new ForcedAuthenticator());
 
session.setDebug(true);
 
MimeMessage message = new MimeMessage(session);
 
try {
    message.setFrom(new InternetAddress(from));
    for (int i=0;i<to.length;i++)
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to[i]));
 
    message.setSubject(subject);
    message.setContent(HtmlMessage, "text/html; charset=\"ISO-8859-2\"");
    Transport.send(message);
}
catch (MessagingException ex){
    System.err.println("Cannot send email. " + ex);
}
Classe pour l'authentification(toujours dans la même classe :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
class ForcedAuthenticator extends Authenticator {
    public PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(user,password);
    }
}
Je vous remercie d'avance pour vos réponses futures et pour votre excellant travail!