This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Accessing custom email headers in bounced back emails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Accessing custom email headers in bounced back emails" Watch "Accessing custom email headers in bounced back emails" New topic
Author

Accessing custom email headers in bounced back emails

p malladi
Greenhorn

Joined: Sep 17, 2009
Posts: 6
Hi,

I have a requirement like this.

I have a program which sends out huge number of emails to customers using java API.

The code snippet is like below
Session session = Session.getDefaultInstance(properties, null);
MimeMessage msg = new MimeMessage(session);
msg.setFrom(fromAddress);
msg.setRecipients(javax.mail.Message.RecipientType.TO, toAddress);
msg.setSubject(emailSubject);
msg.setContent(emailContent, "text/html");
msg.setHeader("user-id","854967125");
msg.saveChanges();
Transport.send(msg);


Here I am setting a custom header before sending a mail to the customer.
I am able to get/read this custom header field "user-id" by using pop3 protocol.
However when the email was sent to an invalid email address the bounce back email doesn't have this custom header field "user-id".
I need this information because I have to update my database that the email address for this particular user-id has bounced.

Is there any thing we can do at the code level to read the custom headers? Or do we have to configure some thing at the mail server level to retain these custom headers in bounced back emails.
Please help me how to achieve this.

Thanks in advance
p malladi
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If the headers aren't in the e-mail which is returned to you then naturally you can't read them from that e-mail.

And yes, this could be fixed by reconfiguring the mail server. However the mail server you would have to reconfigure is the one which is sending you the bounce messages, not your mail server. So you would have to convince a large number of server administrators to reconfigure their servers to make your job easier. That probably isn't going to be a worthwhile exercise.

You should probably consider some more practical way of handling bounce messages, since that way doesn't work. The only tool you really have is the envelope header's Reply-To address. If you included the user ID in that address, then you would get it back because the bounce message would be sent there.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing custom email headers in bounced back emails
 
Similar Threads
JavaMail/James: Handle email bouncebacks?
Handling Bounce Back Emails.
mailing Newsletter to all Subscribers
Sending mails from same domain
JavaMail API and Postmaster undeliverable errors