I can't see anything wrong with how you parse the headers, offhand.
But I'd like to warn you that if you throw away all bounces, you will not know when a mail of yours gets bounced.
Speaking for myself, I wouldn't dare do that: I mistype an email address at least once a week.
-
You could look through the mail message to see if it carries a message-id of the format that comes from your mail server.
- If the bounce includes the headers of the original mail (some, particularly "virus intercepted" ones don't), you could look through those to see if your IP was mentioned.
- You could parse the logs of your mail server and make a note of IDs of outgoing messages
- You could allow bounces in for, say, 10 minutes after you send a message (NOT recommended).
Personaly, I'd parse the logs and look for valid Message-IDs. But it's not foolroof.