Showing posts with label email read. Show all posts
Showing posts with label email read. Show all posts

Sunday, March 27, 2011

Check if email has been read

Hi,

If you are working with newsletters, it is a part of the job to maintain a statistics, of the emails to which the newsletters are send. The statistics may contain, number of bounced mails, number of opened/unopened email and so on. In this post I will explain a method for checking whether an email has been read or not. For checking bounced emails, I hope I will add it as a seperate post.

The idea is very simple. When we are talking of whether an email has been read or not, we basically mean to say  whether the email has been opened or not. For achieving this, following is the technique I have been using in most of my projects.

Assuming we have the following table structure (this is the minimum columns needed, you can change according to your need):



First add a image tag in your email along with the other email contents, and do not mention any size of the image as:

<img src="....." />

The main trick is with the "src" attribute. In the src, instead of using an actual image, enter the path of a PHP file in your server with the full URL of the files as:

<img src="http://localhost/php/ismailopened/opened.php?id=1">

In "?id=1", the value 1 needs to be dynamic. It is the newsletter ID. Now in opened.php I have added the following code:


<?php
if(isset($_GET['id'])){

mysql_pconnect("localhost","root");
mysql_select_db("test");
mysql_query("update newsletter set isopened='1' where id=".$_GET['id']);