jdavidbakr / mail-tracker

Package for Laravel to inject tracking code into outgoing emails.
MIT License
577 stars 129 forks source link

It does not track emails if I update credentials on runtime #118

Closed arkniazi closed 4 years ago

arkniazi commented 4 years ago

I'm trying to update credentials of email client on runtime. Because I'll be sending emails from different accounts.

I'm updating the credentials in following way.

$transport = new \Swift_SmtpTransport( $host, $port, $security);
$transport->setUsername($username);
$transport->setPassword($password);
$mailer->setSwiftMailer(new Swift_Mailer($transport));
jdavidbakr commented 4 years ago

You'll have to duplicate what happens in MailTrackerServiceProvider::registerSwiftPlugin() to reinstall the plugin if you reinstantiate the swift mailer.

arkniazi commented 4 years ago

Okay, got it. It's working fine now. $mailer->getSwiftMailer()->registerPlugin(new MailTracker()); Thanks