I am doing a bounce-email handling with PHP. I have include the return path in the mail function, e.g:
mail($to_address, $subject, $message, $headers, "-f".$return_path ); $return_path = "bounce_handle@domain.com";
Now, what should my php script looks like (and where should i put it) in order to read all the bounce emails? (can show me with some sample code?)
Advertisement
Answer
You’ll need to configure whichever mail transport agent handles (MTA) “bounce_handle@domain.com” to send the mail to the PHP script that does whatever magic you need it to do. The MTA is what actually handles mail coming into the server. There are many different MTA’s, but most of them have some configuration where you can basically tell it to pipe email coming into a certain address into a custom script.
Alternatively, you could setup a mailbox for your bounce handler and have PHP read it via POP3. For this, you’d have to configure an actual email account for your bounce handler. Then you have your PHP script connect to that mailbox using standard protocols. See the php.net documentation on IMAP/POP for how this is accomplished.