diff --git a/composer.json b/composer.json index d1c42e4d1d06..d96877c6a336 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "mtdowling/cron-expression": "~1.0", "nesbot/carbon": "~1.20", "ramsey/uuid": "~3.0", - "swiftmailer/swiftmailer": "~5.4", + "swiftmailer/swiftmailer": "~6.0", "symfony/console": "~3.2", "symfony/debug": "~3.2", "symfony/finder": "~3.2", diff --git a/src/Illuminate/Mail/Message.php b/src/Illuminate/Mail/Message.php index 1b2aa0b3a05b..a4f0e4622d85 100755 --- a/src/Illuminate/Mail/Message.php +++ b/src/Illuminate/Mail/Message.php @@ -236,7 +236,7 @@ public function attachData($data, $name, array $options = []) */ protected function createAttachmentFromData($data, $name) { - return Swift_Attachment::newInstance($data, $name); + return new Swift_Attachment($data, $name); } /** @@ -266,7 +266,7 @@ public function embed($file) */ public function embedData($data, $name, $contentType = null) { - $image = Swift_Image::newInstance($data, $name, $contentType); + $image = new Swift_Image($data, $name, $contentType); return $this->swift->embed($image); } diff --git a/src/Illuminate/Mail/Transport/ArrayTransport.php b/src/Illuminate/Mail/Transport/ArrayTransport.php index 6213b5b2ee17..766af833c35c 100644 --- a/src/Illuminate/Mail/Transport/ArrayTransport.php +++ b/src/Illuminate/Mail/Transport/ArrayTransport.php @@ -2,7 +2,7 @@ namespace Illuminate\Mail\Transport; -use Swift_Mime_Message; +use Swift_Mime_SimpleMessage; use Illuminate\Support\Collection; class ArrayTransport extends Transport @@ -27,7 +27,7 @@ public function __construct() /** * {@inheritdoc} */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { $this->beforeSendPerformed($message); diff --git a/src/Illuminate/Mail/Transport/LogTransport.php b/src/Illuminate/Mail/Transport/LogTransport.php index 26c2c220f0bc..273fb782e4e2 100644 --- a/src/Illuminate/Mail/Transport/LogTransport.php +++ b/src/Illuminate/Mail/Transport/LogTransport.php @@ -2,9 +2,9 @@ namespace Illuminate\Mail\Transport; -use Swift_Mime_Message; -use Swift_Mime_MimeEntity; use Psr\Log\LoggerInterface; +use Swift_Mime_SimpleMessage; +use Swift_Mime_SimpleMimeEntity; class LogTransport extends Transport { @@ -29,7 +29,7 @@ public function __construct(LoggerInterface $logger) /** * {@inheritdoc} */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { $this->beforeSendPerformed($message); @@ -43,10 +43,10 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) /** * Get a loggable string out of a Swiftmailer entity. * - * @param \Swift_Mime_MimeEntity $entity + * @param \Swift_Mime_SimpleMimeEntity $entity * @return string */ - protected function getMimeEntityString(Swift_Mime_MimeEntity $entity) + protected function getMimeEntityString(Swift_Mime_SimpleMimeEntity $entity) { $string = (string) $entity->getHeaders().PHP_EOL.$entity->getBody(); diff --git a/src/Illuminate/Mail/Transport/MailgunTransport.php b/src/Illuminate/Mail/Transport/MailgunTransport.php index 3b486808cfb6..1a730299e341 100644 --- a/src/Illuminate/Mail/Transport/MailgunTransport.php +++ b/src/Illuminate/Mail/Transport/MailgunTransport.php @@ -2,7 +2,7 @@ namespace Illuminate\Mail\Transport; -use Swift_Mime_Message; +use Swift_Mime_SimpleMessage; use GuzzleHttp\ClientInterface; class MailgunTransport extends Transport @@ -53,7 +53,7 @@ public function __construct(ClientInterface $client, $key, $domain) /** * {@inheritdoc} */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { $this->beforeSendPerformed($message); @@ -71,11 +71,11 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) /** * Get the HTTP payload for sending the Mailgun message. * - * @param \Swift_Mime_Message $message + * @param \Swift_Mime_SimpleMessage $message * @param string $to * @return array */ - protected function payload(Swift_Mime_Message $message, $to) + protected function payload(Swift_Mime_SimpleMessage $message, $to) { return [ 'auth' => [ @@ -99,10 +99,10 @@ protected function payload(Swift_Mime_Message $message, $to) /** * Get the "to" payload field for the API request. * - * @param \Swift_Mime_Message $message + * @param \Swift_Mime_SimpleMessage $message * @return string */ - protected function getTo(Swift_Mime_Message $message) + protected function getTo(Swift_Mime_SimpleMessage $message) { return collect($this->allContacts($message))->map(function ($display, $address) { return $display ? $display." <{$address}>" : $address; @@ -112,10 +112,10 @@ protected function getTo(Swift_Mime_Message $message) /** * Get all of the contacts for the message. * - * @param \Swift_Mime_Message $message + * @param \Swift_Mime_SimpleMessage $message * @return array */ - protected function allContacts(Swift_Mime_Message $message) + protected function allContacts(Swift_Mime_SimpleMessage $message) { return array_merge( (array) $message->getTo(), (array) $message->getCc(), (array) $message->getBcc() diff --git a/src/Illuminate/Mail/Transport/MandrillTransport.php b/src/Illuminate/Mail/Transport/MandrillTransport.php index c8fdfa36e876..685b02753df4 100644 --- a/src/Illuminate/Mail/Transport/MandrillTransport.php +++ b/src/Illuminate/Mail/Transport/MandrillTransport.php @@ -2,7 +2,7 @@ namespace Illuminate\Mail\Transport; -use Swift_Mime_Message; +use Swift_Mime_SimpleMessage; use GuzzleHttp\ClientInterface; class MandrillTransport extends Transport @@ -37,7 +37,7 @@ public function __construct(ClientInterface $client, $key) /** * {@inheritdoc} */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { $this->beforeSendPerformed($message); @@ -60,10 +60,10 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) * * Note that Mandrill still respects CC, BCC headers in raw message itself. * - * @param \Swift_Mime_Message $message + * @param \Swift_Mime_SimpleMessage $message * @return array */ - protected function getTo(Swift_Mime_Message $message) + protected function getTo(Swift_Mime_SimpleMessage $message) { $to = []; diff --git a/src/Illuminate/Mail/Transport/SesTransport.php b/src/Illuminate/Mail/Transport/SesTransport.php index a790423a4ad1..c3afe3f5e3bf 100644 --- a/src/Illuminate/Mail/Transport/SesTransport.php +++ b/src/Illuminate/Mail/Transport/SesTransport.php @@ -3,7 +3,7 @@ namespace Illuminate\Mail\Transport; use Aws\Ses\SesClient; -use Swift_Mime_Message; +use Swift_Mime_SimpleMessage; class SesTransport extends Transport { @@ -28,7 +28,7 @@ public function __construct(SesClient $ses) /** * {@inheritdoc} */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { $this->beforeSendPerformed($message); diff --git a/src/Illuminate/Mail/Transport/SparkPostTransport.php b/src/Illuminate/Mail/Transport/SparkPostTransport.php index 0a59bf48c5e0..492ade8df491 100644 --- a/src/Illuminate/Mail/Transport/SparkPostTransport.php +++ b/src/Illuminate/Mail/Transport/SparkPostTransport.php @@ -2,7 +2,7 @@ namespace Illuminate\Mail\Transport; -use Swift_Mime_Message; +use Swift_Mime_SimpleMessage; use GuzzleHttp\ClientInterface; class SparkPostTransport extends Transport @@ -46,7 +46,7 @@ public function __construct(ClientInterface $client, $key, $options = []) /** * {@inheritdoc} */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { $this->beforeSendPerformed($message); @@ -80,10 +80,10 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) * * Note that SparkPost still respects CC, BCC headers in raw message itself. * - * @param \Swift_Mime_Message $message + * @param \Swift_Mime_SimpleMessage $message * @return array */ - protected function getRecipients(Swift_Mime_Message $message) + protected function getRecipients(Swift_Mime_SimpleMessage $message) { $recipients = []; diff --git a/src/Illuminate/Mail/Transport/Transport.php b/src/Illuminate/Mail/Transport/Transport.php index 76e5d527d840..bc2574997369 100644 --- a/src/Illuminate/Mail/Transport/Transport.php +++ b/src/Illuminate/Mail/Transport/Transport.php @@ -3,8 +3,8 @@ namespace Illuminate\Mail\Transport; use Swift_Transport; -use Swift_Mime_Message; use Swift_Events_SendEvent; +use Swift_Mime_SimpleMessage; use Swift_Events_EventListener; abstract class Transport implements Swift_Transport @@ -40,6 +40,14 @@ public function stop() return true; } + /** + * {@inheritdoc} + */ + public function ping() + { + return true; + } + /** * Register a plug-in with the transport. * @@ -54,10 +62,10 @@ public function registerPlugin(Swift_Events_EventListener $plugin) /** * Iterate through registered plugins and execute plugins' methods. * - * @param \Swift_Mime_Message $message + * @param \Swift_Mime_SimpleMessage $message * @return void */ - protected function beforeSendPerformed(Swift_Mime_Message $message) + protected function beforeSendPerformed(Swift_Mime_SimpleMessage $message) { $event = new Swift_Events_SendEvent($this, $message); @@ -71,10 +79,10 @@ protected function beforeSendPerformed(Swift_Mime_Message $message) /** * Iterate through registered plugins and execute plugins' methods. * - * @param \Swift_Mime_Message $message + * @param \Swift_Mime_SimpleMessage $message * @return void */ - protected function sendPerformed(Swift_Mime_Message $message) + protected function sendPerformed(Swift_Mime_SimpleMessage $message) { $event = new Swift_Events_SendEvent($this, $message); @@ -88,10 +96,10 @@ protected function sendPerformed(Swift_Mime_Message $message) /** * Get the number of recipients. * - * @param \Swift_Mime_Message $message + * @param \Swift_Mime_SimpleMessage $message * @return int */ - protected function numberOfRecipients(Swift_Mime_Message $message) + protected function numberOfRecipients(Swift_Mime_SimpleMessage $message) { return count(array_merge( (array) $message->getTo(), (array) $message->getCc(), (array) $message->getBcc() diff --git a/src/Illuminate/Mail/TransportManager.php b/src/Illuminate/Mail/TransportManager.php index b61c945a7bc9..1b3e1817c589 100644 --- a/src/Illuminate/Mail/TransportManager.php +++ b/src/Illuminate/Mail/TransportManager.php @@ -7,11 +7,11 @@ use Psr\Log\LoggerInterface; use Illuminate\Support\Manager; use GuzzleHttp\Client as HttpClient; -use Swift_MailTransport as MailTransport; use Swift_SmtpTransport as SmtpTransport; use Illuminate\Mail\Transport\LogTransport; use Illuminate\Mail\Transport\SesTransport; use Illuminate\Mail\Transport\ArrayTransport; +use Swift_SendmailTransport as MailTransport; use Illuminate\Mail\Transport\MailgunTransport; use Illuminate\Mail\Transport\MandrillTransport; use Illuminate\Mail\Transport\SparkPostTransport; @@ -31,9 +31,7 @@ protected function createSmtpDriver() // The Swift SMTP transport instance will allow us to use any SMTP backend // for delivering mail such as Sendgrid, Amazon SES, or a custom server // a developer has available. We will just pass this configured host. - $transport = SmtpTransport::newInstance( - $config['host'], $config['port'] - ); + $transport = new SmtpTransport($config['host'], $config['port']); if (isset($config['encryption'])) { $transport->setEncryption($config['encryption']); @@ -65,9 +63,7 @@ protected function createSmtpDriver() */ protected function createSendmailDriver() { - return SendmailTransport::newInstance( - $this->app['config']['mail']['sendmail'] - ); + return new SendmailTransport($this->app['config']['mail']['sendmail']); } /** @@ -104,11 +100,11 @@ protected function addSesCredentials(array $config) /** * Create an instance of the Mail Swift Transport driver. * - * @return \Swift_MailTransport + * @return \Swift_SendmailTransport */ protected function createMailDriver() { - return MailTransport::newInstance(); + return new MailTransport(); } /** diff --git a/tests/Mail/MailMailerTest.php b/tests/Mail/MailMailerTest.php index d7fc6ce6667b..1e796979abfb 100755 --- a/tests/Mail/MailMailerTest.php +++ b/tests/Mail/MailMailerTest.php @@ -18,7 +18,7 @@ public function testMailerSendSendsMessageWithProperViewContent() { unset($_SERVER['__mailer.test']); $mailer = $this->getMockBuilder('Illuminate\Mail\Mailer')->setMethods(['createMessage'])->setConstructorArgs($this->getMocks())->getMock(); - $message = m::mock('Swift_Mime_Message'); + $message = m::mock('Swift_Mime_SimpleMessage'); $mailer->expects($this->once())->method('createMessage')->will($this->returnValue($message)); $view = m::mock('StdClass'); $mailer->getViewFactory()->shouldReceive('make')->once()->with('foo', ['data', 'message' => $message])->andReturn($view); @@ -38,7 +38,7 @@ public function testMailerSendSendsMessageWithProperViewContentUsingHtmlStrings( { unset($_SERVER['__mailer.test']); $mailer = $this->getMockBuilder('Illuminate\Mail\Mailer')->setMethods(['createMessage'])->setConstructorArgs($this->getMocks())->getMock(); - $message = m::mock('Swift_Mime_Message'); + $message = m::mock('Swift_Mime_SimpleMessage'); $mailer->expects($this->once())->method('createMessage')->will($this->returnValue($message)); $view = m::mock('StdClass'); $mailer->getViewFactory()->shouldReceive('make')->never(); @@ -59,7 +59,7 @@ public function testMailerSendSendsMessageWithProperPlainViewContent() { unset($_SERVER['__mailer.test']); $mailer = $this->getMockBuilder('Illuminate\Mail\Mailer')->setMethods(['createMessage'])->setConstructorArgs($this->getMocks())->getMock(); - $message = m::mock('Swift_Mime_Message'); + $message = m::mock('Swift_Mime_SimpleMessage'); $mailer->expects($this->once())->method('createMessage')->will($this->returnValue($message)); $view = m::mock('StdClass'); $mailer->getViewFactory()->shouldReceive('make')->once()->with('foo', ['data', 'message' => $message])->andReturn($view); @@ -81,7 +81,7 @@ public function testMailerSendSendsMessageWithProperPlainViewContentWhenExplicit { unset($_SERVER['__mailer.test']); $mailer = $this->getMockBuilder('Illuminate\Mail\Mailer')->setMethods(['createMessage'])->setConstructorArgs($this->getMocks())->getMock(); - $message = m::mock('Swift_Mime_Message'); + $message = m::mock('Swift_Mime_SimpleMessage'); $mailer->expects($this->once())->method('createMessage')->will($this->returnValue($message)); $view = m::mock('StdClass'); $mailer->getViewFactory()->shouldReceive('make')->once()->with('foo', ['data', 'message' => $message])->andReturn($view);