Though this idea might not be applicable for all the cases, but can be of some help. This can be helpful in tracking users for newsletter, campaigns, etc. So following is the code snippet to detect if email is opened using php.
Step 1:
insert a 1 pixel image in the body of email that you create, like
$emailBody = 'This is a test message.';
$emailBody .='';
$emailBody .='Please feel free to contact me..!';
....
.....
//send email using mail() function of php
Step 2:
Create the file take_action_open.php and add following code
//get the userid from url of image source
$userId = $_GET["userid"];
//add code to insert this user to database
//or do something with it.
//this user has opened the email that you have sent.
And thats it. You can track opened emails using this method. As i already
said this method may not be applicable for all cases, since images can be
disabled by some mail services as well. So need to find some other solution
in such cases. However, i think this code might be of some help to someone
like me.
No comments:
Post a Comment