From 5646a258f480bdfdfabd491dd726f37eb50e4a74 Mon Sep 17 00:00:00 2001 From: Bastian Konetzny Date: Tue, 6 Feb 2018 12:51:35 +0100 Subject: [PATCH 1/5] Added type "yii-extension". --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 2a69bd3..5abc270 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,9 @@ { "name": "rdewilde/yiimailer", "description": "Yii extension for sending emails with layouts using PHPMailer", + "type": "yii-extension", "require": { - "php": ">=5.0.0", - "phpmailer/phpmailer": "5.2.*" + "php": ">=5.0.0", + "phpmailer/phpmailer": "5.2.*" } } From 39dc6d7578c5e849e098f252b6d1960fb433333e Mon Sep 17 00:00:00 2001 From: Bastian Konetzny Date: Tue, 6 Feb 2018 13:15:41 +0100 Subject: [PATCH 2/5] Update phpmailer to 6.x release. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5abc270..cb33b8f 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,6 @@ "type": "yii-extension", "require": { "php": ">=5.0.0", - "phpmailer/phpmailer": "5.2.*" + "phpmailer/phpmailer": "^6.0" } } From 33f622f8155741b5701254ea24b5b5e8b0f8e6d9 Mon Sep 17 00:00:00 2001 From: Bastian Konetzny Date: Tue, 6 Feb 2018 13:38:53 +0100 Subject: [PATCH 3/5] Updated YiiMailer to work with PHPMailer 6.x. --- YiiMailer.php | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/YiiMailer.php b/YiiMailer.php index 19a1d4d..2f07d6c 100644 --- a/YiiMailer.php +++ b/YiiMailer.php @@ -27,6 +27,7 @@ * @version 1.6, 2014-07-09 */ +use PHPMailer\PHPMailer\PHPMailer; class YiiMailer extends PHPMailer { @@ -37,12 +38,6 @@ class YiiMailer extends PHPMailer */ public $CharSet = 'UTF-8'; - /** - * Sets the text-only body of the message. - * @var string - */ - public $AltBody = ''; - /** * Default paths and private properties */ @@ -323,7 +318,7 @@ public function getBaseDirPath() */ public function setFrom($address, $name = '', $auto = true) { - return parent::SetFrom($address, $name, (int)$auto); + return parent::setFrom($address, $name, (bool)$auto); } /** @@ -337,7 +332,7 @@ public function setFrom($address, $name = '', $auto = true) */ public function setTo($addresses) { - $this->ClearAddresses(); + $this->clearAddresses(); return $this->setAddresses('to', $addresses); } @@ -348,7 +343,7 @@ public function setTo($addresses) */ public function setCc($addresses) { - $this->ClearCCs(); + $this->clearCCs(); return $this->setAddresses('cc', $addresses); } @@ -359,7 +354,7 @@ public function setCc($addresses) */ public function setBcc($addresses) { - $this->ClearBCCs(); + $this->clearBCCs(); return $this->setAddresses('bcc', $addresses); } @@ -370,7 +365,7 @@ public function setBcc($addresses) */ public function setReplyTo($addresses) { - $this->ClearReplyTos(); + $this->clearReplyTos(); return $this->setAddresses('Reply-To', $addresses); } @@ -389,9 +384,9 @@ private function setAddresses($type, $addresses) $result = true; foreach ($addresses as $key => $value) { if (is_int($key)) - $r = $this->AddAnAddress($type, $value); + $r = $this->addAnAddress($type, $value); else - $r = $this->AddAnAddress($type, $key, $value); + $r = $this->addAnAddress($type, $key, $value); if ($result && !$r) $result = false; } @@ -434,9 +429,9 @@ public function setAttachment($attachments) $result = true; foreach ($attachments as $key => $value) { if (is_int($key)) - $r = $this->AddAttachment($value); + $r = $this->addAttachment($value); else - $r = $this->AddAttachment($key, $value); + $r = $this->addAttachment($key, $value); if ($result && !$r) $result = false; } @@ -449,9 +444,9 @@ public function setAttachment($attachments) */ public function clear() { - $this->ClearAllRecipients(); - $this->ClearReplyTos(); - $this->ClearAttachments(); + $this->clearAllRecipients(); + $this->clearReplyTos(); + $this->clearAttachments(); } /** @@ -543,7 +538,7 @@ public function render() */ protected function MsgHTMLWithLayout($message, $basedir = '') { - $this->MsgHTML($this->renderView($this->layoutPath . '.' . $this->layout, array('content' => $message, 'data' => $this->data)), $basedir); + $this->msgHTML($this->renderView($this->layoutPath . '.' . $this->layout, array('content' => $message, 'data' => $this->data)), $basedir); } /** @@ -558,17 +553,17 @@ public function send() //send the message try { //prepare the message - if (!$this->PreSend()) + if (!$this->preSend()) return false; //in test mode, save message as a file if ($this->testMode) return $this->save(); else - return $this->PostSend(); - } catch (phpmailerException $e) { + return $this->postSend(); + } catch (Exception $e) { $this->mailHeader = ''; - $this->SetError($e->getMessage()); + $this->setError($e->getMessage()); if ($this->exceptions) { throw $e; } @@ -597,12 +592,12 @@ public function save() try { $file = fopen($dir . DIRECTORY_SEPARATOR . $filename, 'w+'); - fwrite($file, $this->GetSentMIMEMessage()); + fwrite($file, $this->getSentMIMEMessage()); fclose($file); return true; } catch (Exception $e) { - $this->SetError($e->getMessage()); + $this->setError($e->getMessage()); return false; } From 6b0a4243a5a8629197c7d1e98b51396c408219d1 Mon Sep 17 00:00:00 2001 From: Bastian Konetzny Date: Tue, 6 Feb 2018 13:45:23 +0100 Subject: [PATCH 4/5] Updated 2.0.0 docs. --- README.md | 4 ++-- YiiMailer.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e754a8f..eabea59 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ Yii (v1.1.x) extension for sending emails with layouts using [PHPMailer](https:/ ## Installation -1. Copy YiiMailer folder to protected/extensions -2. Add 'ext.YiiMailer.YiiMailer' line to your imports in main and/or console yii config +1. Install with composer: `composer require rdewilde/yiimailer` +2. Add 'vendor.rdewilde.yiimailer.YiiMailer' line to your imports in main and/or console yii config 3. Copy mail.php config file to protected/config or add configuration array in 'params' under the key 'YiiMailer' 4. Create email layout file mail.php in protected/views/layouts/ (default path, can be changed in config) 5. Create all the views you want to use in protected/views/mail/ (default path, can be changed in config) diff --git a/YiiMailer.php b/YiiMailer.php index 2f07d6c..bf61231 100644 --- a/YiiMailer.php +++ b/YiiMailer.php @@ -24,7 +24,7 @@ * @author Vernes Šiljegović * @copyright Copyright (c) 2014 YiiMailer * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 1.6, 2014-07-09 + * @version 2.0.0, 2018-02-06 */ use PHPMailer\PHPMailer\PHPMailer; From 496998a803ada9adaa545b2e28675bd790c97ced Mon Sep 17 00:00:00 2001 From: Bastian Konetzny Date: Tue, 6 Feb 2018 13:47:10 +0100 Subject: [PATCH 5/5] Updated 2.0.0 docs. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eabea59..9791222 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Yii (v1.1.x) extension for sending emails with layouts using [PHPMailer](https:/ ## Features -* Based on PHPMailer (bundled, use branch 'composer' for composer support) +* Based on PHPMailer * Supports Yii layouts and translation * Supports web and console applications * Send full HTML emails with embedded images