GeoIP 和 HTML 电子邮件
GeoIP and HTML Email
我编写了一封 HTML 电子邮件,效果很好,并且几乎没有退回邮件。
客户希望根据用户的位置显示或隐藏电子邮件的某些部分。他们没有关于订阅者位置或任何列表细分的数据,所以我制作了一个 PHP 脚本,该脚本从 img
标签的 src
和 returns 图像加载基于用户的 IP,通过 DBIP API 进行地理定位。
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 发送了这个。
我认为这是你的错,因为:
if ($info_array[2] == ("New York" || "Connecticut" || "New Jersey"))
执行顺序如下:
("New York" || "Connecticut" || "New Jersey")
是 true
下一步 - 比较 $info_array[2]
与 true
除空值或零外的任何 $info_array[2]
都将是 true
。
我编写了一封 HTML 电子邮件,效果很好,并且几乎没有退回邮件。
客户希望根据用户的位置显示或隐藏电子邮件的某些部分。他们没有关于订阅者位置或任何列表细分的数据,所以我制作了一个 PHP 脚本,该脚本从 img
标签的 src
和 returns 图像加载基于用户的 IP,通过 DBIP API 进行地理定位。
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 发送了这个。
我认为这是你的错,因为:
if ($info_array[2] == ("New York" || "Connecticut" || "New Jersey"))
执行顺序如下:
("New York" || "Connecticut" || "New Jersey")
是 true
下一步 - 比较 $info_array[2]
与 true
除空值或零外的任何 $info_array[2]
都将是 true
。