and like us on FB

Most web based email software will permit you to determine if an email is read by including a small image into the body of the HTML message. When rendered into an email client a request is made for the image and the server-side fancy work logs the details into a database. The PHP code on this page is designed to emulate the feature just described in a very simple way.

The Result

Following is an example of logs that are recorded when a request for your image is made:

The last record was obtained by inserting the image into an outlook email; the others were accessed via a web browser. I’ve used a simple .htaccess file in the same directory as my code and rewritten the URL referencing the image (as {custom_word}/reademail.jpg). Without the rewrite you should use reademail.php?code={custom_word}.

The last field in the log example above is the custom field custom_word you can use to determine who it was that read an email. Most mass email clients permit you to include a custom field (name, email, id) into the email message and it’s intended that you’ll use one of those here.

The PHP Code

The following code should be copied into a file called reademail.php.

If you plan on rewriting your image URL so it has the .jpg extension you should also include the .htaccess file below. This is a preferred method since it assists the browser or email client in rendering the image as an image rather than gibberish text.

Considerations

  • To validate the ‘custom field’ input I’m using just alphanumeric text, hyphens, and underscores. We validate this in both the PHP script and the .htaccess file. If you choose to include other characters you’ll have to rewrite this. If you were to use an email it may be sensible to hash it so it includes only permitted characters (for example, MD5 will include only [a-fA-F0-9] characters)… or you could just validate the email!
  • To edit the HTML in MS Outlook I use outlookhtmleditor .

Determine if an Email is Read Using PHP (and Log Who Read It)

Outlook HTML Editor (http://outlookhtmleditor.codeplex.com)

  • Rather than just including a pixel-sized image in your email you might consider generating your email (image) signature in the manner described. In addition to logging the read email you can add additional features such as the ability to use specific full-featured image email signatures based on the recipient or your own sender address. You might also consider an action that’ll fire off an email ‘read receipt’. I’ve personally used the signature method to automatically generate different email signatures for specific (and known) recipients.
  • If you were to build this funky little function into an actual tool you use you would almost certainly store data in a database. The text file is prone to errors and it was only used for the purpose of the demonstration.
  • This snipped was migrated from Internoetics without alteration (so it’s a little old).

Shortt URL for this post: http://shor.tt/Ejl