PHP code example of benlehr / mail-campaign-tracker
1. Go to this page and download the library: Download benlehr/mail-campaign-tracker library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
benlehr / mail-campaign-tracker example snippets
// In AppServiceProvider
public function boot()
{
MailTracker::ignoreMigrations();
}
use benlehr\mail-tracker\MailCampaignHelper;
// get the helper
$helper = new MailCampaignHelper();
// create a campaign and get ID
$campaignId = $helper->createCampaign('name of campaign');
// fetch your users
$users = User::all();
foreach ($users as $user) {
// send mail and inject campaign id
Mail::to($user->email)->send(new TestMail($campaignId));
}
namespace App\Listeners;
use benlehr\MailTracker\Events\ViewEmailEvent;
class EmailViewed
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param ViewEmailEvent $event
* @return void
*/
public function handle(ViewEmailEvent $event)
{
// Access the model using $event->sent_email
// Access the IP address that triggered the event using $event->ip_address
}
}
namespace App\Listeners;
use benlehr\MailTracker\Events\PermanentBouncedMessageEvent;
class BouncedEmail
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param PermanentBouncedMessageEvent $event
* @return void
*/
public function handle(PermanentBouncedMessageEvent $event)
{
// Access the email address using $event->email_address
}
}