Home >Backend Development >PHP Tutorial >img src php counts the number of emails opened
The way to count the number of times an email is opened is basically to put a picture in the email, and then count the number of times the picture is opened
mail.html
This way you can The log counts the number of times the image has been opened, but there is an error in the number of times counted. For example, the user opens it multiple times, etc.
In fact, you can also write like this in the email, directly point the src to a php file, and then output the image in the php file.
First try:
mail.html
mail.php
die('mail.jpg');
Open the email like this Sometimes mail.php returns mail.jpg (image address), but the image cannot be loaded.
After a simple check, the header information of the src request in html is Accept: image/png, image/*; q=0.8,*/*; q=0.5, so it is incorrect to output mail.jpg directly. It should be Output the contents of the image.
Modified:
mail.php
readfile('mail.jpg'); //file_get_contents('mail.jpg'); You can also
This way you can count the detailed information of email openings
Of course, you don’t have to worry about this if you don’t display the image. Just modify the img style in the html.