Blog Details


Sent E-mail read or un-read - PHP Code

We are using gmail, yahoo, hotmail etc to send emails to our friends, relatives etc. We dont know whether the email that we sent was read by the recipient or not. To get the read receipts, we need paid accounts from the Mail providers.

Here i am going to show you a simple php program script to get read receipts of the emails that we sent.

$user_id = $_GET['user_id'];

If ( $user_id )
    $FileName = $id.".txt";
    $ourFileHandle = fopen($FileName, 'w') or die("can't open file");
    $to = ""; //to address

    $subject ="Read Receipt Email";

    $message = "Testing whether the read receipt script works or not";
    $message = "     $headers  = 'MIME-Version: 1.0' . "rn";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
    $headers .= 'From:' . "rn";

    if (mail($to, $subject, $message, $headers) )
        echo "Mail sent successfully";
        echo "failed to send mail";


Lets call this php script page name as email.php and the website domain name as The url of this page is

      Now the user_id parameter contains a   When you open this page ( on the browser, then the script first tries to read the get parameter user_id and checks whether there is any value in the parameter.

  •     As there is no value for the user_id parameter, the script goes to the else part and sends an email to the user. The important part here is the image tag in the message.
  •     Once the user receives an email and opens it, the html image tag tries to download a zero pixel image from the site. The url of the image is value. The php script goes to the section and creates an empty file with The creation of the empty file indicates that the user read the email.