Hi,
I set up a small web app and would like to send email, so I am using
google's smtp server. But I get an exception back. Here it is:
org.apache.commons.mail.EmailException: Sending the email to the
following serve
r failed : smtp.gmail.com:465
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:
873)
at org.apache.commons.mail.Email.send(Email.java:898)
at TimeTravelMailer.sendMessage(TimeTravelMailer.java :29)
at CreateAccountServlet.doPost(CreateAccountServlet.java:12)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:
710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java :
803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:269)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java :188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:210)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:174)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:117)
at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineVal
ve.java:108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:151)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:870)
at org.apache.coyote.http11.Http11BaseProtocol
$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool
$ControlRunnable.run(ThreadP
ool.java :685)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.mail.MessagingException: Could not connect to SMTP
host: smtp.g
mail.com, port: 465, response: -1
at
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1270)
at
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:37
0)
at javax.mail.Service.connect(Service.java:297)
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)
... 19 more
What am I doing wrong?
Gordon Beaton - 24 Apr 2007 07:15 GMT
> I set up a small web app and would like to send email, so I am using
> google's smtp server. But I get an exception back. Here it is:
> org.apache.commons.mail.EmailException: Sending the email to the
> following server failed : smtp.gmail.com:465
Enable debugging in your JavaMail program. Post the debug output, and
maybe some code too.
/gordon
--
Greg R. Broderick - 24 Apr 2007 07:57 GMT
mighty.tornado@gmail.com wrote in news:1177379020.756857.185980
@l77g2000hsb.googlegroups.com:
> Hi,
>
> I set up a small web app and would like to send email, so I am using
> google's smtp server. But I get an exception back. Here it is:
[snippage]
> Caused by: javax.mail.MessagingException: Could not connect to SMTP
> host: smtp.g
[quoted text clipped - 14 lines]
>
> What am I doing wrong?
The mail client software (your app) was unable to connect to the mail server
"smtp.gmail.com" on port 465, as the exception message stated. This could be
for any number of reasons, including:
- you have a firewall blocking your host from connecting to a remote host on
port 465.
- gmail's mail server is down and temporarily unreachable
- a router somewhere between your host and smtp.gmail.com is malfunctioning
and preventing a connection
- you aren't using SSL/TLS in your connection to smtp.gmail.com, as is
required, per <http://mail.google.com/support/bin/answer.py?answer=13287
&topic=1556>.
using telnet to connect to the remote host will allow you to determine if the
problem lies within your code (i.e. telnet is able to connect) or outside of
your code (i.e. telnet is also unable to connect). If the problem can be
localized to your code, then JavaMail has a debugging trace option that is
enabled by setting a system property named "mail.debug" to "true" (String
value). This will cause a full transcript of your session with the mail
server to be output to the console, and is quite useful in diagnosing issues
such as this.
In any case, this is something that your code should anticipate and handle
gracefully - your code is dependent upon a resource (the mail server) that is
outside of your control, therefore your code MUST handle this resource being
unavailable, either permanently or temporarily, gracefully.
Cheers!

Signature
---------------------------------------------------------------------
Greg R. Broderick usenet200704@blackholio.dyndns.org
A. Top posters.
Q. What is the most annoying thing on Usenet?
---------------------------------------------------------------------
Roman - 25 Apr 2007 01:58 GMT
Greg,
Thank you - it must have been SSL indeed.
Except I still get the same exception when I try to send from
https://localhost:8443 etc.
Is there a step I missed in configuring SSL on Tomcat?
I presume telnet connection to smtp.gmail.com 465 suceeded because
after I hit run-> telnet smtp.gmail.com 465 the screen went black with
no words or anything.