Tracking Emails with PHP

It often happens that you tend to send an email and wonder if the mail has been received and read. It like a very useful feature to know if the Email has been opened and read! While it is not as difficult as it seems, there are two methods to do this.

1) Insert a Javascript into the email. (I have not explored this, but it wont work in most cases as today’s email services usually block Javascripts from executing within the email.)

2) Using an Image generated by a Server side language and trace requests to it. (Something like PHP will do the job)

Here we’ll use the 2nd method. All you need now is a PHP hosting server. If you dont have one, you can use a freehosting service like Freehostia.

Now, we need just one file. Lets name it as image.php and paste the code given below

Now save any PNG image file that you would like to have in your email, in the same folder as this PHP file, and rename it as “image.png”.

Once you have hosted these two files on your server, open an Rich Text enabled email service like Gmail and insert an Image from URL in your email signature. Paste the URL of the PHP file with your ID attached. Which will look like this. (Here 123 is the unique ID I am using).

If your Email service provides support for HTML emails paste the script below in your email signature.

Send the email! and you are done!!! Check for text files that will be created with the names of your Unique ID. They will look like this
filename: 123.txt
Opened on Fri, 31 Dec 2010 19:15:00 +0530|

There is alot more you can do with it. Using a 1px X 1px image is recommended, as it wont be noticed.

Note: Some email services block images by default from unknown senders. You need to be in the victims contact list or trusted list for this to work.