Home >Backend Development >PHP Tutorial >img src php counts the number of emails opened

img src php counts the number of emails opened

巴扎黑
巴扎黑Original
2016-11-22 15:52:181675browse

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.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Optimize php code tipsNext article:Optimize php code tips