我编写了一封HTML电子邮件,它表现得很好,而且几乎没有反弹。
客户端希望根据用户的位置显示或隐藏电子邮件的某些部分。它们没有关于订阅者位置的数据或任何列表分段,因此我从img标记的src中加载了一个PHP脚本,并通过DBIP返回基于用户IP的图像以进行地理定位。
if ($info_array[1] == "US"){
if ($info_array[2] == ("New York" || "Connecticut" || "New Jersey")){
// log how many see the ny/nj/ct content into count.txt. protections are in place for multiple concurrent accesses
$fp = fopen('count.txt', 'c+');
flock($fp, LOCK_EX);
$count = (int)fread($fp, filesize('count.txt'));
ftruncate($fp, 0);
fseek($fp, 0);
fwrite($fp, $count + 1);
flock($fp, LOCK_UN);
fclose($fp);
// spit out the image
header('Content-Type: image/jpeg');
$image = readfile('box5.jpg');
return $image;
}
else{
header('Content-Type: image/gif');
$image = readfile('spacer.gif');
return $image;
}
}
else{
header('Content-Type: image/gif');
$image = readfile('spacer.gif');
return $image;
}我在本地测试了这一切,似乎一切都很好,但是今天在服务器上打开count.txt时,它显示了8000/9000打开了脚本中的NY/CT/NJ部分,这是疯狂的,因为这个品牌在北美和南美洲很受欢迎。
我的问题是:导致这种情况的是我代码中的错误吗?还是请求来自邮件代理服务器?如果是的话,大多数邮件代理是否都在这些地区?
如果有帮助的话,我是从ExactTarget寄来的。
发布于 2015-05-21 20:06:22
我觉得这是你的错
if ($info_array[2] == ("New York" || "Connecticut" || "New Jersey"))执行顺序如下:
("New York" || "Connecticut" || "New Jersey")是true
下一步--将$info_array[2]与true进行比较
除空值或零外,任何$info_array[2]都将是true。
https://stackoverflow.com/questions/30383193
复制相似问题