Skip to content

Commit

Permalink
Merge pull request #240 from vemaeg/feature/swiftmailer-6-compat-2
Browse files Browse the repository at this point in the history
Add compatibility for Swiftmailer 6 and preserve compatibility with Swiftmailer 5
  • Loading branch information
thePanz authored Mar 24, 2021
2 parents 49245ac + 8ae3232 commit d9a1684
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"require": {
"php" : ">=5.3.0",
"swiftmailer/swiftmailer": "~5.2"
"swiftmailer/swiftmailer": "~5.2 || ^6.0"
},
"require-dev": {
"psr/log": "*"
Expand Down
10 changes: 6 additions & 4 deletions lib/mailer/sfMailer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ public function setDeliveryAddress($address)
*/
public function compose($from = null, $to = null, $subject = null, $body = null)
{
return Swift_Message::newInstance()
$msg = new Swift_Message();

return $msg
->setFrom($from)
->setTo($to)
->setSubject($subject)
Expand Down Expand Up @@ -277,12 +279,12 @@ public function sendNextImmediately()
/**
* Sends the given message.
*
* @param Swift_Transport $transport A transport instance
* @param string[] &$failedRecipients An array of failures by-reference
* @param Swift_Mime_Message|Swift_Mime_SimpleMessage $message The message to send.
* @param string[] &$failedRecipients An array of failures by-reference
*
* @return int|false The number of sent emails
*/
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
public function send($message, &$failedRecipients = null)
{
if ($this->force)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/mailer/sfNoMailer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function sendNextImmediately()
return null;
}

public function send(Swift_Mime_Message $message, &$failedRecipients = null)
public function send($message, &$failedRecipients = null)
{
return null;
}
Expand Down

0 comments on commit d9a1684

Please sign in to comment.