Newsgroup: it.comp.java
Titolo: org.apache.commons.mail.EmailException...aiutatemi!!!

Salve ragazzi,
vorrei chiedervi un aiuto...
sto provando ad aggiungere la funzionalità di invio mail alla mia
applicazione jsf.
Per fare ciò sto provando ad usare il progetto Jakarta commons che
dovrebbe semplificare l'uso delle javamail api. Ho settato classpath e
caricato le  librerie.
Il mio banale metodo è
public String sendMail() throws EmailException{
		SimpleEmail email = new SimpleEmail();
		email.setHostName("
smtp.alice.it
");
		email.addTo("
da...@virgilio.it
", "Paolo Rossi");
				// TODO Auto-generated catch block
		email.setFrom("
gb...@alice.it
", "Marco Bianchi");
		email.setSubject("Test message");
		email.setMsg("This is a simple test of commons-email");
		email.send();
		return "e-mailSend";
	}
Aiutatemi a capire,vorrei inviare un'email da 
gb...@alice.it
 a
da...@virgilio.it
.
Come devo settare email.setHostName?
Premetto che non ho installato nessun server smtp sul mio pc,nè vorrei
farlo.
Posso usare 
alice.it
?
Come?
Con questo codice ho questo errore...vi prego aiutatemiù
GRAVE: #{retrievingData.sendMail}: javax.faces.el.EvaluationException:
org.apache.commons.mail.EmailException: Sending the email to the
following server failed : 
smtp.alice.it:25
javax.faces.FacesException: #{retrievingData.sendMail}:
javax.faces.el.EvaluationException:
org.apache.commons.mail.EmailException: Sending the email to the
following server failed : 
smtp.alice.it:25
	at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
	at javax.faces.component.UICommand.broadcast(UICommand.java:312)
	at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
	at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
	at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
	at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:97)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
	at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
	at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
	at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
	at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.el.EvaluationException:
org.apache.commons.mail.EmailException: Sending the email to the
following server failed : 
smtp.alice.it:25
	at
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:130)
	at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
	... 27 more
Caused by: org.apache.commons.mail.EmailException: Sending the email to
the following server failed : 
smtp.alice.it:25
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:873)
	at org.apache.commons.mail.Email.send(Email.java:898)
	at giu.RetrievingData.sendMail(RetrievingData.java:27)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
	... 28 more
Caused by: javax.mail.MessagingException: Unknown SMTP host:
smtp.alice.it
;
  nested exception is:
	java.net.UnknownHostException: 
smtp.alice.it
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1280)
	at
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
	at javax.mail.Service.connect(Service.java:275)
	at javax.mail.Service.connect(Service.java:156)
	at javax.mail.Service.connect(Service.java:105)
	at javax.mail.Transport.send0(Transport.java:168)
	at javax.mail.Transport.send(Transport.java:98)
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:863)
	... 35 more
Caused by: java.net.UnknownHostException: 
smtp.alice.it
	at java.net.PlainSocketImpl.connect(Unknown Source)
	at java.net.SocksSocketImpl.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at
com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
	at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
	... 42 more
18-nov-2006 17.30.03 org.apache.catalina.core.StandardWrapperValve
invoke
GRAVE: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.FacesException: #{retrievingData.sendMail}:
javax.faces.el.EvaluationException:
org.apache.commons.mail.EmailException: Sending the email to the
following server failed : 
smtp.alice.it:25
	at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
	at javax.faces.component.UICommand.broadcast(UICommand.java:312)
	at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
	at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
	at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
	at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:97)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
	at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
	at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
	at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
	at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.el.EvaluationException:
org.apache.commons.mail.EmailException: Sending the email to the
following server failed : 
smtp.alice.it:25
	at
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:130)
	at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
	... 27 more
Caused by: org.apache.commons.mail.EmailException: Sending the email to
the following server failed : 
smtp.alice.it:25
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:873)
	at org.apache.commons.mail.Email.send(Email.java:898)
	at giu.RetrievingData.sendMail(RetrievingData.java:27)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
	... 28 more
Caused by: javax.mail.MessagingException: Unknown SMTP host:
smtp.alice.it
;
  nested exception is:
	java.net.UnknownHostException: 
smtp.alice.it
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1280)
	at
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
	at javax.mail.Service.connect(Service.java:275)
	at javax.mail.Service.connect(Service.java:156)
	at javax.mail.Service.connect(Service.java:105)
	at javax.mail.Transport.send0(Transport.java:168)
	at javax.mail.Transport.send(Transport.java:98)
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:863)
	... 35 more
Caused by: java.net.UnknownHostException: 
smtp.alice.it
	at java.net.PlainSocketImpl.connect(Unknown Source)
	at java.net.SocksSocketImpl.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at
com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
	at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
	... 42 more

 
smtp.alice.it
;
Questo messaggio è più volte ricorrente nel trace, che avresti dovuto 
leggere anziché incollare ciecamente qui. Ad ogni modo, te lo spiego con 
un esempio:
emanuele@engine:~$ ping 
smtp.alice.it
ping: unknown host 
smtp.alice.it
Il che mi suggerisce che l'SMTP è un altro e non questo.
-- 
Emanuele Torrenti
Registered Linux User #409659
http://torrenti.altervista.org

grazie al tuoi aiuto Manuel ho risolto!!!
In particolare era questa la configurazione giusta,grazie ancora
email.setHostName("
out.alice.it
");