2015-06-10 58 views
0

不工作我tryed如果HTML電子郵件是通過將這樣的圖像打開跟蹤:PHP IMG電子郵件跟蹤即使IMG顯示在客戶

<img height="210px" width="210px" src="http://example.com/emailimg1/c00015.jpg" style="-ms-interpolation-mode: bicubic;"> 

而且我相信,如果顯示圖像那麼它必須從我的網絡服務器上下載。所以我addedd此行的.htaccess:

RewriteRule ^emailimg(.?)/(.*)$ emailTracker.php/$1 

和emailTracker.php如下:

<?php 
require_once'Zend/Loader/Autoloader.php'; 
Zend_Loader_Autoloader::getInstance(); 

include "../phpComp/trackEmail.php"; 

$url = $_SERVER['REQUEST_URI']; 
$pieces = explode("/", $url); 
$imgId = substr($pieces[1], -1); 
$clientHash = substr($pieces[2],0, -4); 
$imgFormat=substr($pieces[2], -4); 

trackEmail($clientHash); 

$filepath="img/email".$imgId.$imgFormat; 

if (file_exists($filepath)) 
{ 
    header("Content-type: image/jpeg"); 
    header("Accept-Ranges: bytes"); 
    header('Content-Length: ' . filesize($filepath)); 
    readfile($filepath); 
} 

和trackEmail.php如下:

<?php 

function trackEmail($clientHash) 
{ 
    date_default_timezone_set('Europe/Rome'); 
    $date = date('Y-m-d H:i:s', time()); 
    $dateDay = date('d-m-Y', time()); 

    try 
    { 
     include_once '../absolute/myConnection.php'; 
     $dbSvr = new Zend_Db_Adapter_Pdo_Mysql($connParams); 
    } 
    catch (Zend_Db_Adapter_Exception $e) 
    { 
     //*******debug**********-> 
     $response=$e->getMessage(); 
     //echo $response; 
     //*******debug**********<- 
    } 
    catch (Zend_Exception $e) 
    { 
     //*******debug**********-> 
     $response=$e->getMessage(); 
     //echo $response; 
     //*******debug**********<- 
    } 
     $data = array(
       'clientHash'=>$clientHash, 
       'date'=>$date 
     ); 
     $insertResult = $dbSvr->insert('emailAccess', $data); 
    } 
    catch (Zend_Exception $e) 
    { 
     //*******debug**********-> 
     $response=$e->getMessage(); 
     //echo $response; 
     //*******debug**********<- 
    } 
} 

這樣:

  • 如果我從瀏覽器訪問我的地址http://example.com/emailimg1/c00015.jpg然後my mySql表正確記錄一個訪問;
  • 如果我發送郵件,然後從eudora桌面,outlook.com從瀏覽器打開它,從Android的Outlook應用程序,然後從mySql記錄訪問。

我的問題是:

  • 我做錯了什麼?
  • 可能是郵件服務器(Zoho)下載img並將其嵌入到html郵件中,因此沒有客戶端正在下載它?

回答

1

幾乎所有的電子郵件客戶端都會因爲用來跟蹤用戶而精確地去掉圖片。這就是爲什麼這不起作用。

+0

這是可以理解的。但實際上這裏發生的事情是img由客戶端顯示,但我的服務器不記錄對該文件的任何訪問。 –