Skip to content

Commit

Permalink
Swiftmailer 6.0 compatibility (#21)
Browse files Browse the repository at this point in the history
* Clean up

* Updated phpunit

* Refactoring for v2

* Refectory for v2 pt2

* Required dev php7

Phpunit v6 requires php7 to run

* Fancy helpers

* Prioritise jobs in background

* Use temp arrays to prioritise jobs

* Coveralls

* Coverall config

* Adjusted waiting time on test

* Typo fix

* Removed deprecated flag

* Added Coverage badge to readme

* Removed psr/log suggestion

* Fixed typo in composer.json

* Fixes from styleci

* Downgraded phpunit

Using an older version of phpunit to allow testing on php5, as phpunit
v6 requires php7

* Added php 7.1 supported version

* More fixes from styleci

* Fixes from styleci

* Reordered badges + styleci badge

* Increased tests waiting time when testing file output

* Typo in the documentation

Ref #16

* Fix #20

Added support for SwiftMailer ^6.0

::newInstance() method has been deprecated, along with
Swift_MailTransport.

The default mail transport is now sendmail when using swiftmailer

https://legalhackers.com/advisories/SwiftMailer-Exploit-Remote-Code-Exec
-CVE-2016-10074-Vuln.html
  • Loading branch information
peppeocchi authored Jul 7, 2017
1 parent ede01ff commit 992d7b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"require-dev": {
"phpunit/phpunit": "~5.7",
"satooshi/php-coveralls": "^1.0",
"swiftmailer/swiftmailer": "~5.4"
"swiftmailer/swiftmailer": "~5.4 || ^6.0"
},
"suggest": {
"swiftmailer/swiftmailer": "Required to send the output of a job to email address/es (~5.4)."
"swiftmailer/swiftmailer": "Required to send the output of a job to email address/es (~5.4 || ^6.0)."
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 3 additions & 5 deletions src/GO/Traits/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getEmailConfig()
if (! isset($this->emailConfig['transport']) ||
! ($this->emailConfig['transport'] instanceof \Swift_Transport)
) {
$this->emailConfig['transport'] = \Swift_MailTransport::newInstance();
$this->emailConfig['transport'] = new \Swift_SendmailTransport();
}

return $this->emailConfig;
Expand All @@ -43,13 +43,11 @@ public function getEmailConfig()
*/
private function sendToEmails(array $files)
{
$mailer = \Swift_Mailer::newInstance(
$this->emailConfig['transport']
);
$mailer = new \Swift_Mailer($this->emailConfig['transport']);

$config = $this->getEmailConfig();

$message = \Swift_Message::newInstance()
$message = (new \Swift_Message())
->setSubject($config['subject'])
->setFrom($config['from'])
->setTo($this->emailTo)
Expand Down

0 comments on commit 992d7b0

Please sign in to comment.