Getting notification that an email was opened.
Add Header to email:
Disposition-Notification-To: you@yourdomain.com
As mentioned above it's not reliable and it's better to do something like this:
And log it in a database, although again this is restricted by the email client's ability to show images and sometimes it may even put the mail into junk because it doesn't detect an image... a workaround that would be to actually outputting an image (say your logo) at the end of that script.
Edit: A quick lookup at the phpmailer class gave me the following:
$mail->ConfirmReadingTo = 'yourown@emailaddress.com';
but it's the same as the Disposition-Notification-To method above.
Send a beacon image in the emails like so
And then use the beacon.php file to log the data. You will then want to output a 1X1 image with appropriate headers.
Important note
Many popular email clients (such as Gmail) now block external images, so this is by far, not fool proof.
// HTML
// (inside "record.php")
header('Content-Type: image/gif');
if(isset($_GET['e']))
{
//validate and record click-through here
}
//push out image
if(ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); }
header('Pragma: public'); // required
header('Expires: 0'); // no cache
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private',false);
header('Content-Disposition: attachment; filename="blank.gif"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize('blank.gif')); // provide file size
readfile('blank.gif'); // push it out
exit();
// from another article--> make if a gif
$im=imagecreatetruecolor(1,1); // initialising the image object and asigning its simensions
$white=imagecolorallocate($im,255,255,255); // creating the color object for white color
imagefilledrectangle($im,0,0,1,1,$white); // creating a white rectangle to the image object
header("content-type: image/jpeg"); // creating an image header for returning an image to the src
imagejpeg($im); // image is being created
Please dont do this for public facing services. This is almost 100% considered "questionable" activity in email. Many applications will block this behaviour directly, and many scanning applications will look for images that cannot be seen by the user (0,0 size, 100% transparent, etc) – GrayWizardx Jan 7 '10 at 18:51
1
I agree with GrayWizard, it's better to include a real image in the email, like a logo, and send the unique ID inside the url like
; and that url spits out the mime header & binary data for an actual image, not a HTML page.