This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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?
It sounds like Tomcat is using localhost as a default because it never picks up that parameter setting. Bill
Joined: Feb 04, 2003
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.
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 ]