I coded up an HTML email, which rendered fine, and delivered with few bounces.
The client wanted to show or hide certain sections of the email depending on the user's location. They don't have data on their subscriber's locations or any list segmentation, so I made a PHP script that is loaded from an img
tag's src
, and returns the image based on the IP of the user via the DBIP API for geolocation.
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;
}
I tested this locally and all seemed to be well and good, but upon opening count.txt on the server today it showed that 8000/9000 opens activated the NY/CT/NJ part of the script, which is crazy because the brand is popular all over North / South America.
My question is: is it a fault in my code that caused this? Or would the request have come from mail proxy servers? If so, are most mail proxies in these areas?
If it helps, I sent this from ExactTarget.