The mail() function works great to send out email. However, sometimes an email will bounce due to a mailbox over quota, mailbox deleted, etc.
How can I direct the bounced emails back to a PHP script so I can process and log them them automatically in MySQL rather than having to read through them manually?
The best idea I can come up with so far is to use a cron job that periodically runs a script that will check a POP account and see if any bounced mail has arrived. Is there any way that the arrival of the bounced mail can trigger execution of the script rather than constantly poll the POP account?
I would think this would be a common task for mail list managers to keep track of bouncing email addresses, but I have not seen it done in PHP.