• Post Reply Bookmark Topic Watch Topic
  • New Topic

javax.mail api creating multiple recipients  RSS feed

 
Kevin Towery
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have run into an issue where I have an application that is using javax.mail to send out emails to a smtp server with attachments. When the app has a high number of emails sent out, the smtp server's policy engine gets hung up. The feedback is indicating that the app has sent an email with the same recipient multiple times along with the same attachment multiple times. So you have one email, with say john.doe@doe.com 64 times and the same attachment 64 times. When reviewing the app logs they indicate that one email was sent with one email address in the emailTo field and one attachment. When looking at the app code, it appears that the only thing that is slightly out of the ordinary is that a variable of session.getTransport is declared and then used to invoke javax.mail.send. Due to overhead the mail.debug is turned off on both the app's servers and on the email relay servers.
So I'm wondering if anyone has seen this happen before or have any thoughts about what could be causing this type of problem?

public void sendEmail(Session session, Message msg, TransportAdapter tAdapter) throws NoSuchProviderException, MessagingException {

try {

Transport x = session.getTransport(msg.getRecipients(Message.RecipientType.TO)[0]);

if (tAdapter != null) {
x.addTransportListener(new TestTransportAdapter());
}
x.send(msg);

Thanks,
Kevin
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

I'm not sure that's the problem, but it seems possible that session.getTransport returns the same Transport object every time it's called. If that's the case, then you'd be adding a TransportListener for every single email you're sending, and consequently whatever happens in TestTransportAdapter would be happening multiple times for each email sent. Just a wild guess, though.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!