From 99d8216103a55064ddd73d5fd347ea2fadc94bd7 Mon Sep 17 00:00:00 2001 From: Paul Klimov Date: Tue, 29 Oct 2013 16:11:57 +0200 Subject: [PATCH] Email message charset setup added. --- .../swiftmailer/yii/swiftmailer/Message.php | 20 +++++++++++++++++-- framework/yii/mail/BaseMessage.php | 1 + framework/yii/mail/MessageInterface.php | 6 ++++++ tests/unit/framework/mail/BaseMailerTest.php | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/extensions/swiftmailer/yii/swiftmailer/Message.php b/extensions/swiftmailer/yii/swiftmailer/Message.php index 42d25e7197..89a871de00 100644 --- a/extensions/swiftmailer/yii/swiftmailer/Message.php +++ b/extensions/swiftmailer/yii/swiftmailer/Message.php @@ -39,6 +39,22 @@ class Message extends BaseMessage return $this->_swiftMessage; } + /** + * @inheritdoc + */ + public function setCharset($charset) + { + $this->getSwiftMessage()->setCharset($charset); + } + + /** + * @return string the character set of this message. + */ + public function getCharset() + { + return $this->getSwiftMessage()->getCharset(); + } + /** * @inheritdoc */ @@ -232,8 +248,8 @@ class Message extends BaseMessage { $embedFile = \Swift_EmbeddedFile::newInstance($content); if (!empty($options['fileName'])) { - $embedFile->setFilename($options['fileName']); - } + $embedFile->setFilename($options['fileName']); + } if (!empty($options['contentType'])) { $embedFile->setContentType($options['contentType']); } diff --git a/framework/yii/mail/BaseMessage.php b/framework/yii/mail/BaseMessage.php index 8c4daa8508..a6415216d4 100644 --- a/framework/yii/mail/BaseMessage.php +++ b/framework/yii/mail/BaseMessage.php @@ -21,6 +21,7 @@ use Yii; * @see BaseMailer * * @property \yii\mail\BaseMailer $mailer mailer component instance. This property is read-only. + * @property string $charset the character set of this message. * @property string|array $from sender email address. * @property string|array $to receiver email address. * @property string|array $cc copy receiver email address. diff --git a/framework/yii/mail/MessageInterface.php b/framework/yii/mail/MessageInterface.php index e7de37bd5e..171c4f34a4 100644 --- a/framework/yii/mail/MessageInterface.php +++ b/framework/yii/mail/MessageInterface.php @@ -15,6 +15,12 @@ namespace yii\mail; */ interface MessageInterface { + /** + * Set the character set of this message. + * @param string $charset character set name. + */ + public function setCharset($charset); + /** * Sets message sender. * @param string|array $from sender email address. diff --git a/tests/unit/framework/mail/BaseMailerTest.php b/tests/unit/framework/mail/BaseMailerTest.php index ab70563bb2..178165709d 100644 --- a/tests/unit/framework/mail/BaseMailerTest.php +++ b/tests/unit/framework/mail/BaseMailerTest.php @@ -168,6 +168,8 @@ class Message extends BaseMessage public $id; public $encoding; + public function setCharset($charset) {} + public function setFrom($from) {} public function setTo($to) {}