The concept around this is to serve a 1px image through a PHP script. This allows you to insert a new record or update an existing one about read mails.
In your mail you only have to insert an image tag like this at the end of the template:
<img src="<?php echo url_for('stats/image?bulletin='.$id, 'absolute=true') ?>" alt="px.gif" />
And inside your actions.class.php:
public function executeImage()
{
if ($bulletin = BulletinPeer::retrieveByPk($this->getRequestParameter('bulletin')))
{
// We do database stuff here
}
// And serve our image
$this->redirect('http://'.$_SERVER['SERVER_NAME'].'/images/px.gif');
}
Update:
You can specify a routing rule to match /px.gif?bulletin=id (I don’t remember if you have to modify .htaccess in /web)
3 Comments on “How to count the opening of bulletin e-mail with Symfony”
You can track this conversation through its atom feed.
Yeah. But how do you cope with most of the emails programs banning images from the email view panel?
(And they ban the image for that precise reason).
Posted on November 23, 2008 at 7:53 pm.
Well, if I subscribe to an e-mail bulletin I usually want to read the content clearly, so I deactivate the image e-mail load restriction.
Spam is not my business, you know
I accept other suggestions =)
Posted on November 24, 2008 at 10:51 am.
Touché!
Posted on November 25, 2008 at 3:25 am.