Tracking the opening of emails (Отслеживание открытия писем)

Last update: 22 Квітня, 2023

Category: E-mail, Form

img.php

<?php
// генерируем картинку и отдаем ее 
$image = imagecreatetruecolor(1,1); // создаем холст 1 на 1 пиксель
imagefill($image, 0, 0, 0xFFFFFF); // делаем его белым
header('Content-type: image/png'); // задаем заголовок
imagepng($image); // выводим картинку
imagedestroy($image); // очищаем память от картинки
 
// ведем статистику
//if(isset($_GET['code'])){
    //shipit_m1_
    
   // $email = base64_decode($_GET['code']); // получили email пользователя, который открыл письмо
    $email = $_GET['code'];
    $file = 'stata.txt';
    $current = file_get_contents($file);
    $current .= "\n".$email;
    file_put_contents($file, $current);      
    fclose ($file);    
//}
?>

.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ([[:alnum:]]+).png$ img.php?code=$1 [L]
</IfModule>

index.php

<?php header("Location: https://site.com/"); exit;