johnsmith153 Posted November 3, 2009 Share Posted November 3, 2009 Is it possible to track emails sent out? This must be done in PHP, not using a mailing service. I want to send a variety of emails, then have a record of who has read them and which were never received. Quote Link to comment https://forums.phpfreaks.com/topic/180063-tracking-email-sent/ Share on other sites More sharing options...
.josh Posted November 3, 2009 Share Posted November 3, 2009 You can put an image in your email and the image src will point to a php (or other server-side language). You will send out the emails with a unique id generated for each email, to be put as a param in the image src url. For example, email 1 gets: <img src='yoursite.com/tracker.php?id=1' width='1' height='1' /> email 2 gets: <img src='yoursite.com/tracker.php?id=2' width='1' height='1' /> etc... dunno what system you are using to send out these emails, but a lot of mass mailer/mailing list programs have the ability to auto-generate a number like that. Or you could write up your own basic emailing script and inject it yourself. Or hack an existing one, whatever. When the user opens the email, the image request will be made to your tracker.php script. Your tracker.php script will grab the id, and record the viewing in a database or flatfile. It can be as simple as a single column of ids, as they come in. That way you will have a list of all ids of emails viewed, and can compare that to your overall list. The tracker.php will then, as a response to the email image request, output a raw image. Just a simple 1x1 transparent pixel. Or, if you are already going to have another image in your email somewhere, you can have it output that, instead. You will have to accept a margin of error, because while most email providers do allow images, a lot of them ask the user if they want to view them, or the user can flag in their settings to never view images. Can't get around that. A lot of people put a "click here if you have difficulty viewing" link in there, to try and get the user to click on that link and go to a live webpage version of your email. Passing the unique id in the link and tracking it there. Quote Link to comment https://forums.phpfreaks.com/topic/180063-tracking-email-sent/#findComment-949924 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.