• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown

Accessing custom email headers in bounced back emails

Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.setRecipients(javax.mail.Message.RecipientType.TO, toAddress);
msg.setContent(emailContent, "text/html");

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
Posts: 27987
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic