September 11, 2015

PHP send email and when click on any link of that email than how to track.



Following is example for track email viewed OR not?

<?php
$user_id = $_GET['user_id'];

If ( $user_id )
{
    $FileName = $id.".txt";
    $ourFileHandle = fopen($FileName, 'w') or die("can't open file");
    fclose($ourFileHandle);
}
else
{
    $to = "jhon@gmail.com"; //to address

    $subject ="Read Receipt Email";

    $message = "Testing whether the read receipt script works or not";
    $message = "<img src=\"http://www.example.com/email.php?user_id=".$to." width=\"0\" height=\"0\" >";
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: kelly@ymail.com' . "\r\n";

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

?>

Enjoy!

No comments:

Post a Comment

Integrating Google reCAPTCHA v3 in HTML Form with PHP

  What is Google reCAPTCHA v3? Google reCAPTCHA is a free service that helps protect websites from spam and abuse. reCAPTCHA v3 is the lates...