diff --git a/README.md b/README.md index e754a8f..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 @@ -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 19a1d4d..bf61231 100644 --- a/YiiMailer.php +++ b/YiiMailer.php @@ -24,9 +24,10 @@ * @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; 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; } diff --git a/composer.json b/composer.json index 2a69bd3..cb33b8f 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": "^6.0" } }