duan198811 2013-11-04 22:29
浏览 159
已采纳

PHP电子邮件像素跟踪在雅虎邮件中不起作用

In order to track email open rates, I'm firing a pixel in a mass email I'm sending from my server. The script is working in Mac Mail. The email is received and the pixel is downloaded.

However, it's not working in the Yahoo mail client. The email is received, the referenced images are downloaded and shown, however the pixel does not fire/download, nor does the php script run (to my knowledge). Does anyone know why this would happen with Yahoo mail client and potentially other clients that I have yet to test?

Here is the html img tag:

<img src="http://mysite.com/email_track.php?email=email_value&country=country_value&state=state_value" />

Here is the php script:

<?php


// Database code omitted

$result= mysql_query("INSERT INTO `CelebrationOpens` SET `time` = NOW(), `country` = '$country', `state` = '$state', `email` = '$email' ") or die(mysql_error());

// Create an image, 1x1 pixel in size
$im=imagecreate(1,1);

// Set the background colour
$white=imagecolorallocate($im,255,255,255);

// Allocate the background colour
imagesetpixel($im,1,1,$white);

// Set the image type
header("content-type:image/jpg");

// Create a JPEG file from the image
imagejpeg($im);

// Free memory associated with the image
imagedestroy($im);

?>

I've also tried to fire the pixel like this:

$name = './concert/pixel.png';
$fp = fopen($name, 'rb');


header("Content-Type: image/png");
header("Content-Length: " . filesize($name));

fpassthru($fp);
exit;

展开全部

  • 写回答

2条回答 默认 最新

  • dongyaoxiu6244 2013-11-06 18:13
    关注

    I was able to find the culprit, and it was related to caching the pixel link. I appended a random string to the img src and it works in both ymail and gmail now.

    The image tag now looks something like this:

    <img src="http://mysite.com/email_track.php?email=email_value&country=country_value&state=state_value&random_value=<?php echo rand() ?>" />
    

    Thanks for the help in guiding me towards this discovery.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部