Dear all,
Yes you have all given me great advice and I appreciate it. Like I
mentioned this is a random issue that occurs, and currently it is
working fine. So when it goes down again I will try out some of your
suggestions. As for the code its a basic spring bean setup for the mailer
<bean id="mailSender"
class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host"><value>smtp.xxx.xxx</value></property>
</bean>
Then in my java code I have a service class that I call whenever I want
to send a message
private void sendMsg(String subject, String msgString, String[] toMail,
String fromMail, String[] ccMail) throws FRSException {
try {
SimpleMailMessage msg = new SimpleMailMessage();
msg.setTo(toMail) {
if ( ccMail != null) {
msg.setCc(ccMail);
}
msg.setSubject(subject);
msg.setFrom(fromMail);
msg.setSentDate(Calendar.getInstance().getTime());
msg.setText(new String(msgString));
mailSender.send(msg);
} catch (MailException me) {
logger.error(me);
throw new FRSException(me.getMessage());
}
}
Fargusson.Alan wrote:
I see you got a number of good suggestions. If you still have this problem you
could try doing a netstat command to see if your server is holding the
connections to the SMTP server. I have seen this type of thing cause some
weird problems.
If your server is holding several connections to the SMTP server it would mean
that the application isn't closing the socket when it is done.
-----Original Message-----
From: Raymond Holguin [mailto:[EMAIL PROTECTED]
Sent: Friday, May 04, 2007 12:38 PM
To: users@tomcat.apache.org
Subject: Tomcat randomly cannot connect to SMTP host
Hello,
I have tomcat 5.0.28 running on my Linux machine, and all my
applications running under this tomcat experience the same problem at
the same time which is why I believe it to be a tomcat issue.
When my applications attempt to send out an email I get this error message
(Mail server connection failed; nested exception is
javax.mail.MessagingException: Could not connect to SMTP host: xxxxxx,
port: 25; nested exception is: java.net.ConnectException: Connection
refused)
The SMTP server is fine, because I can use it from other applications
not on that tomcat server. I can also telnet into the SMTP server just
fine from that same machine, so i don't believe its a server/port
blocking issue on the OS or hardware level. The only way I am able to
resolve the problem is to restart Tomcat. Once Tomcat is restarted,
then all operation with emailing works fine again. I cannot seem to
force the issue to happen so i don't know how reproduce it on demand,
even though I know that would help in solving the issue. This problem
just seems to come up randomly and wont go away until I restart tomcat.
If anyone can please help me solve this issue that would be greatly
appreciated. I have important applications running on this machine and
its a great inconvenience to those using the applications when this
problem comes up.
Thank you
-Ray
--
------------------------------------------------------------------------
Raymond Holguin
Programmer Analyst
College of Humanities, Arts, and Social Sciences
Tel: (951) 827-6212
Email: [EMAIL PROTECTED]
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]