How to track how many times an email was opened by using PHP

In this tutorial I will explain how you can create a simple PHP script to track how many times an email was opened. I will present you my own method.

First, in my email messagge I will insert this code: <img src="second.php"> The second.php file is a file on my server that will track the time.

In my second.php file I will write this code:

$i = 1;
while($i < 10000000):
sleep(1); // after one second this function will write the time in the time.txt file.
$a = fopen("time.txt", "w+");
fwrite($a, $i);
fclose($a);
$i++;
endwhile;

I have used a txt file, but you can use a sql query with update.

In this way you can track how many times an email was opened!

Video tutorial:









Leave a Comment