From fdc29d3aeca1abd49f81e48fb4846c2886a30ae8 Mon Sep 17 00:00:00 2001 From: michu2k Date: Sun, 18 Nov 2018 18:31:35 +0100 Subject: [PATCH] Updated PHPMailer in contact module --- inc/modules/contact/Site.php | 18 +++++++++--------- inc/modules/contact/view/admin/settings.html | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/inc/modules/contact/Site.php b/inc/modules/contact/Site.php index bddab1b..84d1b95 100644 --- a/inc/modules/contact/Site.php +++ b/inc/modules/contact/Site.php @@ -69,7 +69,7 @@ class Site extends SiteModule if ($settings['driver'] == 'mail') { $this->email['sender'] = $this->settings('settings', 'title')." "; - } elseif ($settings['driver'] == 'phpmailer' && class_exists('PHPMailer')) { + } elseif ($settings['driver'] == 'phpmailer' && class_exists('PHPMailer\PHPMailer\PHPMailer')) { $this->email['sender'] = [ $this->settings('contact', 'phpmailer.username'), $this->settings('contact', 'phpmailer.name'), @@ -135,14 +135,14 @@ class Site extends SiteModule $settings = $this->settings('contact'); try { - $mail = new \PHPMailer(true); + $mail = new \PHPMailer\PHPMailer\PHPMailer(true); $mail->isSMTP(); // Set mailer to use SMTP - $mail->Host = $settings['phpmailer.server']; // Specify main and backup SMTP servers - $mail->SMTPAuth = true; // Enable SMTP authentication - $mail->Username = $settings['phpmailer.username']; // SMTP username - $mail->Password = $settings['phpmailer.password']; // SMTP password - $mail->SMTPSecure = 'TLS'; // Enable TLS encryption, `ssl` also accepted - $mail->Port = $settings['phpmailer.port']; // TCP port to connect to + $mail->Host = $settings['phpmailer.server']; // Specify main and backup SMTP servers + $mail->SMTPAuth = true; // Enable SMTP authentication + $mail->Username = $settings['phpmailer.username']; // SMTP username + $mail->Password = $settings['phpmailer.password']; // SMTP password + $mail->SMTPSecure = 'TLS'; // Enable TLS encryption, `ssl` also accepted + $mail->Port = $settings['phpmailer.port']; // TCP port to connect to $mail->CharSet = 'UTF-8'; $mail->Subject = $this->email['subject']; @@ -166,7 +166,7 @@ class Site extends SiteModule $cookieParams = session_get_cookie_params(); setcookie("MailWasSend", 'BATFLAT', time()+360, $cookieParams["path"], $cookieParams["domain"], null, true); } - } catch (\phpmailerException $e) { + } catch (\Exception $e) { $this->_error = $e->errorMessage(); } catch (\Exception $e) { $this->_error = $e->getMessage(); diff --git a/inc/modules/contact/view/admin/settings.html b/inc/modules/contact/view/admin/settings.html index c14183d..3886458 100644 --- a/inc/modules/contact/view/admin/settings.html +++ b/inc/modules/contact/view/admin/settings.html @@ -47,7 +47,7 @@
- {if: !class_exists("PHPMailer")} + {if: !class_exists("PHPMailer\PHPMailer\PHPMailer")}
{$lang.contact.phpmailer_error}
{/if}