My application is delivering automated E-mail notifications to the registered users. I would like to find a way to use the undeliverable mail notifications sent by the remote servers to save the E-mail addresses as failed. In other words, I would ideally want to find a way to, when an undeliverable mail notice is received, execute a program with the E-mail as argument.
-- Pierre
If you are able to, adjust the messages you send to use VERP. By using VERP, basically every email you send will contain a unique envelope sender. When the message is bounced is returned to your mail server you can look at the unique envelop sender and properly modify, disable or handle the bounced message.
As to how to do this, there are many tools, but they depend on the mail server. With some mail servers like exim it is very easy to setup a router+transport that will automatically deliver the message to your application. If you don't want to do that use one of the many programming APIs to access your message store and process them. Again, the exact details depends on your mail server, and how you are able to access it.