Accessing custom email headers in bounced back emails
Joined: Sep 17, 2009
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);
MimeMessagemsg = new MimeMessage(session);
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.
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.