Hi,
Thanks for trying to help.
Our company uses Cisco's IronPort for emails. Not fully sure if it is Load Balancer, but there is some mechanism thats supposed to round-robin the requests (to mailo2) to all the servers.
From the application code perspective, we do not manage connections on our end. The class that sends the mail(I tried attaching the class, but coderanch didnt let me):
public class MessageEmailServiceImpl implements MessageEmailService ,BeanFactoryAware {
private MessageService messageService;
private
String from;
private String replyTo;
private int maxRetryCount;
private BeanFactory beanFactory;
public void sendMessage(final Message message, final MemberProgram memberProgram) {
JavaMailSender mailSender=getMailSenderNewInstance();
MimeMessage mimeMessage = mailSender.createMimeMessage();
try {
MimeMessageHelper msgHelper = new MimeMessageHelper(mimeMessage, true);
msgHelper.setTo(memberProgram.getEmailAddress());
msgHelper.setFrom(from);
msgHelper.setReplyTo(replyTo);
msgHelper.setSubject(message.getSubjectLine());
String htmlText = "<html><body><img src='cid:emailLogo'><p>" +
"<span style='font-size: 14px;font-family: Arial'>" + message.getMessageBody() + "</span></body></html>";
msgHelper.setText(htmlText, true);
ClassPathResource resource = new ClassPathResource("emailHeaderLogo.jpg");
msgHelper.addInline("emailLogo", resource);
mailSender.send(mimeMessage);
} catch (Exception sendException) {
String msg = "message [" + message.getId() + "] not sent to member program [" + memberProgram.getId() + "] - " + sendException;
Logger.getLogger(MessageEmailServiceImpl.class).info(msg);
FailedEmailRecipient failedEmailRecipient = new FailedEmailRecipient(message, memberProgram);
messageService.save(failedEmailRecipient);
}
}
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory= beanFactory;
}
private JavaMailSender getMailSenderNewInstance(){
JavaMailSender mailSender= (JavaMailSender)this.beanFactory.getBean("mailSender");
return mailSender;
}
}
The JavaMailSenderImpl is configured with the smtp host and port.
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl" scope="prototype">
<property name="host" value="mailo2.cname.com"/>
<property name="port" value="25"/>
</bean>
The sendMessage method of the attached MessageEmailServiceImpl gets repeatedly called in a loop for all the messages that are to be sent.
Thanks,
Tony