Taking action on the failing recipient
Now that you have got the failing recipient, the task would be to record his bounce history and take relevant action. A recommended approach would be to maintain a bounce records table in the database, which would store the failed recipient, bounce-timestamp and failure reason. This can be inserted into the database on every bounce processed, and can be as simple as: /** extractHeaders is defined above */ $bounceHeaders = self::extractHeaders( $email ); $failureReason = $bounceHeaders[ ‘subject’ ]; $bounceTimestamp = $bounceHeaders[ ‘date’ ]; $hashedTo = $bounceHeaders[ ‘to’ ]; // This will hold the VERP address $failedRecipient = self::extractToAddress( $hashedTo ); $con = mysqli_connect( "database_server", "dbuser", "dbpass", "databaseName" ); mysqli_query( $con, "INSERT INTO bounceRecords( failedRecipient, bounceTimestamp, failureReason )VALUES ( $failedRecipient, $bounceTimestamp , $failureReason);
mysqlI_close( $con );