| Author |
java mail - smtp config problem
|
Torque
Greenhorn
Joined: Feb 04, 2003
Posts: 4
|
|
I'm trying to send mail from my JSP app. I've followed the instructions for configuring my server.xml to specify the address of my ISP's smtp server, as in: <Resource name="mail/Session" auth="Container" type="javax.mail.Session"/> <ResourceParams name="mail/Session"> <parameter> <name>mail.smtp.host</name> <value>smtp.myservername.com</value> </parameter> </ResourceParams> The odd thing is, I get an error message: javax.servlet.ServletException: Sending failed; nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; So it looks as though tomcat is looking for the SMTP host on localhost, rather than on the SMTP server I specified. With a Google search I found a few people asking the same question but no answers, so I guess it's something silly they figured out eventually. Any ideas?
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
|
|
It sounds like Tomcat is using localhost as a default because it never picks up that parameter setting. Bill
|
 |
Torque
Greenhorn
Joined: Feb 04, 2003
Posts: 4
|
|
It's 18 months later and I had a PM asking how I'd solved the problem. My memory is a bit scratchy, but I think it was that I had a case difference between the server.xml and web.xml, where the web.xml has an entry like this: <resource-ref> <res-ref-name>mail/Session</res-ref-name> <res-type>javax.mail.Session</res-type> <res-auth>Container</res-auth> </resource-ref> If I remember rightly, I had Session (capital S) in one place and session (small s) in the other. Just one of those stupid gotchas that eats programming time. Hope this helps someone.
|
 |
Sunesh Kumar
Ranch Hand
Joined: Oct 17, 2005
Posts: 89
|
|
Hi, I too getting the same error. I am using netBeans5.0 can any ine please suggest me the solutions. javax.servlet.ServletException: Could not connect to SMTP host: localhost, port: 25 Bye
|
Thanks & Regards<br />Sunesh Kumar Baachu
|
 |
Sivaraman Lakshmanan
Ranch Hand
Joined: Aug 02, 2003
Posts: 231
|
|
Hi, Try pinging the mail server.
|
Regards,
Sivaraman.L
|
 |
Darren Edwards
Ranch Hand
Joined: Aug 17, 2005
Posts: 69
|
|
Is there meant to be a mailserver running on the localhost, or is the mailserver configuration being ignored? If you're having problems with configuration this JDBC / Javamail Setup may help ... [ July 10, 2007: Message edited by: Darren Edwards ]
|
 |
Anoop Keni
Greenhorn
Joined: Jul 29, 2004
Posts: 3
|
|
I too had a similar issue of mail not being sent and got the following message javax.servlet.ServletException: Could not connect to SMTP host: localhost, port: 25 I had to check my application's context.xml in /webroot/META-INF The problem was "Session" was "session". I changed small "s" to caps "S". Location 1: <Resource name="mail/Session" type="javax.mail.Session"/> Location 2: <ResourceParams name="mail/Session"> <parameter> <name>mail.smtp.port</name> <value>25</value> </parameter> <parameter> <name>mail.smtp.host</name> <value>smtp.myservername.com</value> </parameter> </ResourceParams> Thanks to Torque for scratching his head.  [ September 08, 2006: Message edited by: Anoop Keni ] [ September 08, 2006: Message edited by: Anoop Keni ]
|
 |
 |
|
|
subject: java mail - smtp config problem
|
|
|