Email Tracking using "image" method won't work with Gmail

时间:2019-04-17 00:11:30

标签: php html image email server

If I'm not being clear about anything let me know... I'm new to SO.

I'm having troubles getting Gmail to approve of my image URL that will activate my PHP script to track when people open my emails.

Gmail only allows me to "insert" photos that are specifically image files, such as png or jpg files. I have tried using a file-include mechanism: http://www.example.com/?file=image.png with a two-line PHP script that includes the png file and then writes to a log all the tracking info. However, I have found this doesn't work since I'm technically referencing index.php in the URL.

I have also tried http://www.example.com/script.php where script.php would look like this:

<img src=image.png>
<?php
// write "Someone viewed your mail" in logs
?>

This doesn't work either because I'm still referencing a PHP file.

I'm using the Insert Photo > Web Address feature in Gmail... should I be inserting the file differently to fix my problem? I need to find a way to directly reference an image file on my server but also activate the PHP script.

Any ideas? Am I overlooking something obvious?

1 个答案:

答案 0 :(得分:0)

想通了我可以使用 Thunderbird 做到这一点:

写入->插入-> HTML

在HTML框中:

<img src="www.mysite.com/script.php">

希望这对遇到我问题的人有帮助