Just tested mailgun through its API.
Everything is working fine.
Short: How to track unique opens for a specific mail through webhooks.
Best way to track email openings is so called "pixel". First you need to inject pixel in your email.
For example:
public function insertPixel($user,$template)
{
$output = $template.'';
return $output;
}
Which points to php endpoint. At that endpoint you will get openings and do w/e you want with them.
For example:
public function actionTrack()
{
if (isset($_GET["id"])&&isset($_GET["user"])){
Yii::app()->db->createCommand("UPDATE mailing_campaigns SET open_count = open_count + 1 WHERE id=:id")
->bindParam(":id",$_GET["id"],PDO::PARAM_INT)
->execute();
}
header('Content-Type: image/gif');
echo "\x47\x49\x46\x38\x37\x61\x1\x0\x1\x0\x80\x0\x0\xfc\x6a\x6c\x0\x0\x0\x2c\x0\x0\x0\x0\x1\x0\x1\x0\x0\x2\x2\x44\x1\x0\x3b";
exit;
}
This code adjusts open's counter for mailing campaign for example and returns 1x1 transparent .gif
image.
It's not 100% precise because some people not loading images in emails, but its best way I know so far.