diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index b992b6a..1c5e3ad 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -7,8 +7,10 @@ ### Additional info -| Q | A -| ---------------- | --- -| Yii version | -| PHP version | -| Operating system | +| Q | A +| ----------------------- | --- +| Yii version | +| Yii SwiftMailer version | +| SwiftMailer version | +| PHP version | +| Operating system | diff --git a/.travis.yml b/.travis.yml index e012be7..6c6c483 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,8 @@ language: php php: - - 5.4 - - 5.5 - - 5.6 - 7.0 - - hhvm + - 7.1 # faster builds on new travis setup not using sudo sudo: false diff --git a/CHANGELOG.md b/CHANGELOG.md index a597514..f923dde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ Yii Framework 2 swiftmailer extension Change Log ================================================ -2.0.8 under development +2.1.0 under development ----------------------- -- no changes in this release. +- Enh #31: Added support for SwiftMailer 6.0.x (klimov-paul) 2.0.7 May 01, 2017 diff --git a/Mailer.php b/Mailer.php index 5c92f53..9124be2 100644 --- a/Mailer.php +++ b/Mailer.php @@ -37,7 +37,7 @@ use yii\mail\BaseMailer; * ``` * * You may also skip the configuration of the [[transport]] property. In that case, the default - * PHP `mail()` function will be used to send emails. + * `\Swift_SendmailTransport` transport will be used to send emails. * * You specify the transport constructor arguments using 'constructArgs' key in the config. * You can also specify the list of plugins, which should be registered to the transport using @@ -140,6 +140,7 @@ class Mailer extends BaseMailer */ protected function sendMessage($message) { + /* @var $message Message */ $address = $message->getTo(); if (is_array($address)) { $address = implode(', ', array_keys($address)); @@ -155,7 +156,7 @@ class Mailer extends BaseMailer */ protected function createSwiftMailer() { - return \Swift_Mailer::newInstance($this->getTransport()); + return new \Swift_Mailer($this->getTransport()); } /** @@ -167,7 +168,7 @@ class Mailer extends BaseMailer protected function createTransport(array $config) { if (!isset($config['class'])) { - $config['class'] = 'Swift_MailTransport'; + $config['class'] = 'Swift_SendmailTransport'; } if (isset($config['plugins'])) { $plugins = $config['plugins']; @@ -187,7 +188,7 @@ class Mailer extends BaseMailer ]; } - /* @var $transport \Swift_MailTransport */ + /* @var $transport \Swift_Transport */ $transport = $this->createSwiftObject($config); if (!empty($plugins)) { foreach ($plugins as $plugin) { diff --git a/Message.php b/Message.php index bf0d552..2744e0c 100644 --- a/Message.php +++ b/Message.php @@ -283,7 +283,7 @@ class Message extends BaseMessage */ public function attachContent($content, array $options = []) { - $attachment = \Swift_Attachment::newInstance($content); + $attachment = new \Swift_Attachment($content); if (!empty($options['fileName'])) { $attachment->setFilename($options['fileName']); } @@ -316,7 +316,7 @@ class Message extends BaseMessage */ public function embedContent($content, array $options = []) { - $embedFile = \Swift_EmbeddedFile::newInstance($content); + $embedFile = new \Swift_EmbeddedFile($content); if (!empty($options['fileName'])) { $embedFile->setFilename($options['fileName']); } diff --git a/README.md b/README.md index 0c51c73..3cdd733 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ php composer.phar require --prefer-dist yiisoft/yii2-swiftmailer or add ```json -"yiisoft/yii2-swiftmailer": "~2.0.0" +"yiisoft/yii2-swiftmailer": "~2.1.0" ``` to the require section of your composer.json. diff --git a/UPGRADE.md b/UPGRADE.md new file mode 100644 index 0000000..c73aa34 --- /dev/null +++ b/UPGRADE.md @@ -0,0 +1,19 @@ +Upgrading Instructions for Yii Framework v2 +=========================================== + +!!!IMPORTANT!!! + +The following upgrading instructions are cumulative. That is, +if you want to upgrade from version A to version C and there is +version B between A and C, you need to following the instructions +for both A and B. + +Upgrade from Yii 2.0.7 +---------------------- + +* Minimal required version of the [swiftmailer/swiftmailer](https://github.com/swiftmailer/swiftmailer) library has been raised to 6.0.0. + You should adjust your program according to the [change list](https://github.com/swiftmailer/swiftmailer/blob/v6.0.0/CHANGES#L4-L17) for this version. + +* Since `Swift_MailTransport` has been removed in SwiftMailer 6.0.0, this extension now uses `Swift_SendmailTransport` by default. + +* Minimum version of PHP has been raised to 7.0. diff --git a/composer.json b/composer.json index af955d0..00c7014 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ ], "require": { "yiisoft/yii2": "~2.0.4", - "swiftmailer/swiftmailer": "~5.0" + "swiftmailer/swiftmailer": "~6.0" }, "autoload": { "psr-4": { "yii\\swiftmailer\\": "" } diff --git a/tests/MailerTest.php b/tests/MailerTest.php index 56cafbe..5926e6a 100644 --- a/tests/MailerTest.php +++ b/tests/MailerTest.php @@ -34,7 +34,7 @@ class MailerTest extends TestCase { $mailer = new Mailer(); - $transport = \Swift_MailTransport::newInstance(); + $transport = new \Swift_SendmailTransport(); $mailer->setTransport($transport); $this->assertEquals($transport, $mailer->getTransport(), 'Unable to setup transport!'); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 52c43d8..caf694a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,6 +12,4 @@ require_once(__DIR__ . '/../vendor/autoload.php'); require_once(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); Yii::setAlias('@yiiunit/extensions/swiftmailer', __DIR__); -Yii::setAlias('@yii/swiftmailer', dirname(__DIR__)); - -require_once(__DIR__ . '/compatibility.php'); \ No newline at end of file +Yii::setAlias('@yii/swiftmailer', dirname(__DIR__)); \ No newline at end of file diff --git a/tests/compatibility.php b/tests/compatibility.php deleted file mode 100644 index ee617ab..0000000 --- a/tests/compatibility.php +++ /dev/null @@ -1,16 +0,0 @@ -