Support for laravel 9
I saw that the composer.json was updated in master to support Laravel 9 but there are a couple of other changes necessary to support L9 since the Swift Mailer was replaced with the Symfony Mailer.
The Log driver and InboundEmail files needed updates. I implemented to be backward compatible by checking the app()->version() in each instance. I also added a run-tests action to test against L6-9 on php 7.3, 8 and 8.1 I confirmed that all tests failed prior to my changes and they all pass on all supported php/laravel combinations.
@samtlewis @mpociot it will be really helpful if we can merge this asap.
^ Ditto. I would love to use this on a Laravel 9 app.
@samtlewis have you got this working in production or staging or even local yet? I've pulled it in and all my app does is attempt to forward any email that arrives but it throws this error:
Symfony\Component\Mime\Message::setBody(): Argument #1 ($body) must be of type ?Symfony\Component\Mime\Part\AbstractPart, string given
The stacktrace ends with this:
#0 ...snip.../vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(23): Symfony\\Component\\Mime\\Message->setBody()
#1 ...snip.../vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(52): Illuminate\\Mail\\Message->forwardCallTo()
#2 ...snip.../vendor/laravel/framework/src/Illuminate/Mail/Message.php(368): Illuminate\\Mail\\Message->forwardDecoratedCallTo()
#3 ...snip.../vendor/beyondcode/laravel-mailbox/src/InboundEmail.php(171): Illuminate\\Mail\\Message->__call()
#4 ...snip.../vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(267): BeyondCode\\Mailbox\\InboundEmail->BeyondCode\\Mailbox\\{closure}()
#5 ...snip.../vendor/laravel/framework/src/Illuminate/Mail/MailManager.php(505): Illuminate\\Mail\\Mailer->send()
#6 ...snip.../vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(337): Illuminate\\Mail\\MailManager->__call()
#7 ...snip.../vendor/beyondcode/laravel-mailbox/src/InboundEmail.php(172): Illuminate\\Support\\Facades\\Facade::__callStatic()
#8 ...snip.../app/Providers/AppServiceProvider.php(119): BeyondCode\\Mailbox\\InboundEmail->forward()
Scratching my head at the moment!
@samtlewis - I've looked again at the changes you've made and they don't seem quite right. Apologies if I'm missing something obvious.
if (app()->version() >= 9) {
$mailable->withSwiftMessage(function (\Swift_Message $message) {
$message->getHeaders()->addIdHeader('In-Reply-To', $this->id());
});
} else {
$mailable->withSymfonyMessage(function (\Swift_Message $message) {
$message->getHeaders()->addIdHeader('In-Reply-To', $this->id());
});
}
- Shouldn't the conditional be the other way round? For Laravel 9+ it should be Symfony not Swift?
- When calling withSymfonyMessage it won't be a Swift_Message that is passed?
It still doesn't explain my issue with forwarding. At the moment I think we're going to have to wait until @sschlein or @mpociot have time to give the package a Laravel 9 facelift
@colinmackinlay i believe you are correct. That code is backwards. I am using the ingestion functionality but not reply/forwarding. Probably should have added some tests for that.
@samtlewis implemented in my fork: joelharkes/laravel-mailbox version 3.0.0
Thank you, and sorry that it took so long