From 9b6bdc1bd6a9cb5bf811f9378d400a064086240b Mon Sep 17 00:00:00 2001 From: alextselegidis Date: Mon, 24 Oct 2016 22:56:09 +0200 Subject: [PATCH] There must always be one PHPMailer instance per email (fixes #192). --- src/engine/Notifications/Email.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/engine/Notifications/Email.php b/src/engine/Notifications/Email.php index 591459b9..f17dc3a2 100644 --- a/src/engine/Notifications/Email.php +++ b/src/engine/Notifications/Email.php @@ -135,7 +135,7 @@ class Email { if (!$mailer->Send()) { throw new \RuntimeException('Email could not been sent. Mailer Error (Line ' . __LINE__ . '): ' - . $this->mailer->ErrorInfo); + . $mailer->ErrorInfo); } } @@ -193,16 +193,18 @@ class Email { $html = file_get_contents(__DIR__ . '/../../application/views/emails/delete_appointment.php'); $html = $this->_replaceTemplateVariables($replaceArray, $html); - // Send email to recipient. - $this->mailer->From = $company['company_email']; - $this->mailer->FromName = $company['company_name']; - $this->mailer->AddAddress($recipientEmail->get()); // "Name" argument crushes the phpmailer class. - $this->mailer->Subject = $this->framework->lang->line('appointment_cancelled_title'); - $this->mailer->Body = $html; + $mailer = $this->_createMailer(); - if (!$this->mailer->Send()) { + // Send email to recipient. + $mailer->From = $company['company_email']; + $mailer->FromName = $company['company_name']; + $mailer->AddAddress($recipientEmail->get()); // "Name" argument crushes the phpmailer class. + $mailer->Subject = $this->framework->lang->line('appointment_cancelled_title'); + $mailer->Body = $html; + + if (!$mailer->Send()) { throw new \RuntimeException('Email could not been sent. Mailer Error (Line ' . __LINE__ . '): ' - . $this->mailer->ErrorInfo); + . $mailer->ErrorInfo); } } @@ -236,7 +238,7 @@ class Email { if (!$mailer->Send()) { throw new \RuntimeException('Email could not been sent. Mailer Error (Line ' . __LINE__ . '): ' - . $this->mailer->ErrorInfo); + . $mailer->ErrorInfo); } }