Bonjour,
J'essaye de faire un envoie de mail, j'ai fait beaucoup de recherche et regarder pas mal de tuto. Mais je parviens pas à trouvé mon erreur
voila mon code:
quand je lance ma fonction j'ai cette 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 @Resource(name="mail/equinoxe-software") private Session session; public NewUserMailMDBean() { } public void onMessage(Message msg) { if(msg instanceof TextMessage) { Properties props = session.getProperties(); final String username = (String) props.get("mail.smtp.user"); System.out.println("user :" + username); final String password = (String) props.get("mail.smtp.password"); System.out.println("password :" + password); props.setProperty("mail.transport.protocol", "smtp"); props.setProperty("mail.host", "smtp.xxxxx.fr"); props.setProperty("mail.port", "25"); props.setProperty("mail.smtp.auth", "true"); Session sessionmail = Session.getDefaultInstance(props, new Authenticator(){ @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); sessionmail.setDebug(true); try { javax.mail.Message mesg = new MimeMessage(sessionmail); mesg.setFrom(new InternetAddress(username)); System.out.println("*****Adresse TO ****"); mesg.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress("xxxxx@xxxxx.fr")); mesg.setSubject("mailObjet"); mesg.setText("mailText"); Transport transport = sessionmail.getTransport("smtp"); System.out.println("transport: "+transport.getURLName()); transport.connect("smtp.xxxxx.fr",username, password); transport.sendMessage(mesg, mesg.getAllRecipients()); transport.close(); System.out.println("*****mail is sent****"); System.out.println(" sortie fonction SenderMail----->"); } catch (MessagingException ex) { System.out.println("*****exception****"); while ((ex = (MessagingException)ex.getNextException()) != null) { ex.printStackTrace(); } } }
Le problème vient surement de l'authentification, mais je trouve pas
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 user :logexploit@equinoxe-software.fr password :equinoxe DEBUG: setDebug: JavaMail version 1.4.1 *****Adresse TO **** DEBUG: mail.smtp.class property exists and points to com.sun.mail.smtp.SMTPTransport transport: smtp: DEBUG SMTP: useEhlo true, useAuth true DEBUG SMTP: trying to connect to host "smtp.xxxxx.fr", port 25, isSSL false DEBUG SMTP: exception reading response: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? *****exception**** MQRA:OMR:run:Caught Exception from onMessage():Redelivering:message-driven bean method public abstract void javax.jms.MessageListener.onMessage(javax.jms.Message) system exception MQRA:OMR:run:Exhausted redeliveryAttempts-msg=com.sun.messaging.jms.ra.DirectTextPacket@73534 MQRA:OMR:run:Exhausted redeliveryAttempts-spec=ActvationSpec configuration= DestinationType =javax.jms.Queue Destination =PhysicalQueue MessageSelector =null AcknowledgeMode =Auto-acknowledge SubscriptionDurability =NonDurable ClientId =null SubscriptionName =null EndpointPoolMaxSize =32 EndpointPoolSteadySize =0 EndpointPoolResizeCount =8 EndpointPoolResizeTimeout =600 EndpointExceptionRedeliveryAttempts =1 EndpointExceptionRedeliveryInterval =500 SendUndeliverableMsgsToDMQ =true GroupName =null RAUID =null InClusteredContainer =false MdbName =null UserName =null EnableDirect =true AddressList (in effect) =localhost:7676 MQRA:OMR:run:Message returned & marked for routing to the DMQ MQRA:OMR:run:omrId=0:Acked Undeliverable-Msg=com.sun.messaging.jms.ra.DirectTextPacket@73534 MDB00037 : [TrainingApp2:NewUserMailMDBean]: Exception d'appel du bean message-driven : [javax.ejb.EJBException] javax.ejb.EJBException javax.ejb.EJBException at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:3894) at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3794) at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3596) at com.sun.ejb.containers.MessageBeanContainer.afterMessageDeliveryInternal(MessageBeanContainer.java:1226) at com.sun.ejb.containers.MessageBeanContainer.afterMessageDelivery(MessageBeanContainer.java:1197) at com.sun.ejb.containers.MessageBeanListenerImpl.afterMessageDelivery(MessageBeanListenerImpl.java:79) at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:139) at $Proxy53.afterDelivery(Unknown Source) at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:324) at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:76) at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555) Caused by: java.lang.ClassCastException: javax.net.ssl.SSLException at com.otherway.training.ejb3.mdb.NewUserMailMDBean.onMessage(NewUserMailMDBean.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011) at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175) at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2920) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4011) at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1111) at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:74) at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:179) at $Proxy53.onMessage(Unknown Source) at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:258) ... 2 more
Une idée?
Partager