PHP send email request read receipt


When users using Emails function in some web base application (like sugarcrm, joomla), they might need to request read receipt from the recipients.
Here is a simple tutorial on how to add in the “Request read receipt” in email while send out email thru PHP.

I am using the phpmailer class to develop the feature, please download it from the source forge.

Here is the simple script to send out email and request for read receipt.

* Simple example script using PHPMailer with exceptions enabled
* @package phpmailer
* @version $Id$
require ('../class.phpmailer.php');
try {
        $mail = new PHPMailer(true); //New instance, with exceptions enabled
        $body             = "Please return read receipt to me.";
        $body             = preg_replace('/\\\\/','', $body); //Strip backslashes
        $mail->IsSMTP();                           // tell the class to use SMTP
        $mail->SMTPAuth   = true;                  // enable SMTP authentication
        $mail->Port       = 25;                    // set the SMTP server port
        $mail->Host       = "SMTP SERVER IP/DOMAIN"; // SMTP server
        $mail->Username   = "EMAIL USER ACCOUNT";     // SMTP server username
        $mail->Password   = "EMAIL USER PASSWORD";            // SMTP server password
        $mail->IsSendmail();  // tell the class to use Sendmail
        $mail->AddReplyTo("[email protected]","SOMEONE");
        $mail->From       = "[email protected]";
        $mail->FromName   = "SOMEONE";
        $to = "[email protected]";
        $mail->Subject  = "First PHPMailer Message[Test Read Receipt]";
        $mail->ConfirmReadingTo = "[email protected]"; //this is the command to request for read receipt. The read receipt email will send to the email address.
        $mail->AltBody    = "Please return read receipt to me."; // optional, comment out and test
        $mail->WordWrap   = 80; // set word wrap
        $mail->IsHTML(true); // send as HTML
        echo 'Message has been sent.';
} catch (phpmailerException $e) {
        echo $e->errorMessage();

Some modification need to be done in above script.
1. Configure SMTP mail server.
2. Set the correct FROM & FROM Name ([email protected], SOMEONE)
3. Set the correct TO address

Tested done with Microsoft Outlook 2007.

2 Comments to “PHP send email request read receipt”

  1. hussam 17 April 2012 at 9:28 pm #

    I used this function and I successfully sent emails to a gmail account, but I tried to yahoo and to other accounts and they do not recieves any email

    I am still using it on my machin locally, but it sends the emails.

    do you have an experience??


  2. h2Guru 18 April 2012 at 12:57 pm #

    Hi hussam,

    2 things you might want to check out.
    1. Yahoo/Hotmail spam folder.
    2. Gmail sent folder.

    And you may try to use different SMTP server instead of Gmail. (Gmail have very strong SPAM control over its own SMTP server.)

Leave a Reply