Gmail SMTP server requires TLS and it does not use the default port of 25.
According to this link:
http://mail.google.com/support/bin/answer.py?hl=en&answer=13287
You must use port 456 or 587 for SMTP.
However, port is not an option YET in the latest release. (unless
1.2.16 has been release)
Here is what Curt replied with.
"
log4j.appender.YOURAPPENDERNAME.smtpUsername=USERNAME
log4j.appender.YOURAPPENDERNAME.smtpPassword=PASSWORD
log4j.appender.YOURAPPENDERNAME.smtpPort=PORT
Port is in the current source, but not in the last release. We need
to cut a log4j
1.2.16 soon.
"
Quoting Massimo Quagliani <[EMAIL PROTECTED]>:
Hi,
I have the following problem using SMTPAppender,
Actually the email does not arrive to the mailbox and I got the
following error:
log4j:ERROR Error occured while sending e-mail notification.
javax.mail.MessagingException: Could not connect to SMTP host:
smtp.gmail.com, port: 25;
nested exception is:
java.net.ConnectException: Connection timed out: connect
The log4j.properties contains:
log4j.rootCategory=info, dest1, dest3, email
# Email appender
log4j.appender.email=org.apache.log4j.net.SMTPAppender
log4j.appender.email.BufferSize=25
log4j.appender.email.SMTPHost=smtp.gmail.com
log4j.appender.email.SMTPUsername=<valid_username>
log4j.appender.email.SMTPPassword=<valid_password>
[EMAIL PROTECTED]
[EMAIL PROTECTED]
log4j.appender.email.Subject=Error
log4j.appender.email.layout=org.apache.log4j.PatternLayout
log4j.appender.email.layout.ConversionPattern= %d{DATE} %-5p %m -
%c{3} [%t] [%r ms]%n%n
log4j.appender.email.threshold=ERROR
I am using eclipse on my PC for this try.
Please could you help me to find the solution to this nasty problem?
Thanks in advance, below is the complete stack trace
2008-12-03 18:23:38,296 ERROR [http-8080-1] : This is a
try!
log4j:ERROR Error occured while sending e-mail notification.
javax.mail.MessagingException: Could not connect to SMTP host:
smtp.gmail.com, port: 25;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391)
at
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412
)
at javax.mail.Service.connect(Service.java:310)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at javax.mail.Transport.send0(Transport.java:188)
at javax.mail.Transport.send(Transport.java:118)
at
org.apache.log4j.net.SMTPAppender.sendBuffer(SMTPAppender.java:330)
at
org.apache.log4j.net.SMTPAppender.append(SMTPAppender.java:215)
at
org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(
AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.error(Category.java:305)
at servlet.Log4jServlet.doGet(Log4jServlet.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli
cationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi
lterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVa
lve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextVa
lve.java:175)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.ja
va:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.ja
va:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValv
e.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java
:286)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
844)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proces
s(Http11Protocol.java:583)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447
)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
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:233)
at
com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
... 28 more
--
"We are what we repeatedly do. Excellence, then, is not an act, but a habit."
Aristotle