How do I read those emails ?
How do i stimulate my code when i get the bounced mail?
The problem is how do you know an email you receive is a notification of a delivery failure. As I pointed out last time you posted this, there are
no SMTP reply codes which indicate deliver failure because an address does not exist. You can read the
RFC to confirm this if you like.
The closest you can get with SMTP is a user defined field. The problem is that it is
user defined, not standard. Looking at our company's SMTP server, it seems to generate an "X-Postfix" header which a delivery failure message. So if I knew that every email sent from my server goes to a server of the same type, I could parse the headers of all received messages to spot these failures. However as soon as a message goes to a different server type, I can't guarentee this header will be in the message.
You could also try to parse the email's subject - many servers include something like "Undelivered Mail Returned to Sender" as a subject. This isn't a cast iron route though, becuse what subject the server uses is up to the server's specific configuration and there is no requirement in SMTP to even send a delivery failure message.
You could also write a Transport implementation for whichever server you are using which gives more functionality than is defined in SMTP. This way you could interpret problems such as invalid domains. But you still couldn't guarentee any info on nonexistant users in an existing domain.
You could also check your address domains by trying to connect to them before sending any email - using java.net.*. This would give you a quick
test to see if domains are invalid. But of course you'd have to write this carefully, since domains may be
temporarily unavailable.
[ February 23, 2005: Message edited by: Paul Sturrock ]