0

I am using CodeIgniter to send mass mails to people on a school account. When the email returns "Mail Delivery Error", I want the error email to be sent to the school, and not to the $from address.

The sending and receiving of emails works fine, but is there a way for Codeigniter or PHP to catch the mail delivery error and send it to another email address?

Something like:

CodeIgniter - $this -> email -> mail_delivery

or PHP - mail_delivery_error()

bytecode77
  • 12,331
  • 27
  • 101
  • 126
Rickus Harmse
  • 576
  • 1
  • 6
  • 21

2 Answers2

0

The bounces are handled by the return path header of the mail. You can modify the header to point to the right location. This answer explains return path in detail. This answer explains how to do it in PHP

Community
  • 1
  • 1
kranthi117
  • 588
  • 1
  • 7
  • 19
  • So if I understard correctly, this should set the return path: `mail($to, $subject, $message, $headers, "-f $school_email");` – Rickus Harmse Sep 01 '15 at 12:02
0

PHP has no visibility of the email after it has handed it over to the MTA. To make an intelligent bounce handler you first need to route the bounce messages back to a PHP script. Then your script needs to be able to identify the message as a bounce rather than a temporary failure or an unsollicited email and act on it accordingly.

Community
  • 1
  • 1
symcbean
  • 45,607
  • 5
  • 49
  • 83
  • This is the closest to what I am looking for so far, because the average user of our system is not too clued up and might not know what the mail delivery error mails they will get means, with this I can create an email to send to the user to tell them what the problem was? – Rickus Harmse Sep 01 '15 at 12:16