I'm using Javamail to send e-mails to administrator of an application, with a copy to the interested user. These e-mails are sent with a technical address, so when the primary recipient turns to be invalid (it could occur), only the technical address receives the failed delivery notification.
I want the copy address(es) to receive this notification as well.
But the way it works is quite nebulous for me, especially the DeliveryStatus class.
Does some of you guys already used this package? Or have a link to some example/tutorial. I failed to find something interesting...
The description of the package in that documentation says:
Support for creating and parsing Delivery Status Notifications.
So, if you get a DSN then you can parse it using code from this package. Or if you're writing a mail server, you could use code from this package to create a DSN.
You'll notice it doesn't mention anything about requesting a DSN, which is what your question is about. So you're looking in the wrong place; except that the documentation does provide links to the RFCs which specify DSNs. One or both of them (I read them but don't remember which) describes how to change your e-mail message so that you're more likely to get a DSN.
Unfortunately my experience consists of only a couple of hours perusing the RFCs and trying a few modifications to our existing e-mail-sending code. So I don't have an answer to that specific question. Sorry.
I looked for a way to change the recipient of the DSN - to set the copy address as the recipient instead of the "from" address - at the message level but it seems it is not possible, as DSN mechanisms are handled at MTA level.
Then I looked for an equivalent to the RRT header but found nothing.
I will look for another way, for instance sending the e-mail on behalf of the user which need to receive the failed delivery notification.