From c8c7179342bb4f8fe7e3aa81f681e211fc094888 Mon Sep 17 00:00:00 2001 From: Sam Lewis Date: Fri, 11 Mar 2022 18:47:06 -0500 Subject: [PATCH 01/10] Laravel 9 updates --- .github/workflows/run-tests.yml | 46 +++++++++++++++++++++++++++++++++ src/Drivers/Log.php | 8 +++++- src/InboundEmail.php | 12 ++++++--- 3 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..37e59b5 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,46 @@ +name: run-tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + php: [7.3,8.0] + laravel: [9.*, 8.*] + stability: [prefer-stable] + include: + - laravel: 9.* + testbench: 7.* + - laravel: 8.* + testbench: 6.23 + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + +# - name: Setup problem matchers +# run: | +# echo "::add-matcher::${{ runner.tool_cache }}/php.json" +# echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" +# + - name: Install dependencies + run: | + composer install + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --${{ matrix.stability }} --prefer-dist --no-interaction + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/src/Drivers/Log.php b/src/Drivers/Log.php index 6459db9..7391bf5 100644 --- a/src/Drivers/Log.php +++ b/src/Drivers/Log.php @@ -19,9 +19,15 @@ public function processLog(MessageSent $event) return; } + if(app()->version() >= 9) { + $message = $event->sent->toString(); + } else { + $message = $event->message; + } + /** @var InboundEmail $modelClass */ $modelClass = config('mailbox.model'); - $email = $modelClass::fromMessage($event->message); + $email = $modelClass::fromMessage($message); Mailbox::callMailboxes($email); } diff --git a/src/InboundEmail.php b/src/InboundEmail.php index 9e7949f..5bfe6d4 100644 --- a/src/InboundEmail.php +++ b/src/InboundEmail.php @@ -149,9 +149,15 @@ public function message(): MimeMessage public function reply(Mailable $mailable) { if ($mailable instanceof \Illuminate\Mail\Mailable) { - $mailable->withSwiftMessage(function (\Swift_Message $message) { - $message->getHeaders()->addIdHeader('In-Reply-To', $this->id()); - }); + 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()); + }); + } } return Mail::to($this->from())->send($mailable); From f9ef3baadf22bf160e09b16864dd6710f0ab22c6 Mon Sep 17 00:00:00 2001 From: Sam Lewis Date: Fri, 11 Mar 2022 18:54:20 -0500 Subject: [PATCH 02/10] Only test on php8 since L9 requires it --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 37e59b5..c07dd84 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,7 +9,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [7.3,8.0] + php: [8.0] laravel: [9.*, 8.*] stability: [prefer-stable] include: From 5deded48158fa1398812a5095330f19426565a6a Mon Sep 17 00:00:00 2001 From: Sam Lewis Date: Sat, 12 Mar 2022 09:07:50 -0500 Subject: [PATCH 03/10] Try running matrix to include L6-9 --- .github/workflows/run-tests.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c07dd84..f43467a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,14 +9,20 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.0] - laravel: [9.*, 8.*] stability: [prefer-stable] include: - laravel: 9.* testbench: 7.* + php: 8.0 - laravel: 8.* testbench: 6.23 + php: 8.0 + - laravel: 7.* + testbench: 6.23 + php: 7.3 + - laravel: 6.* + testbench: 6.23 + php: 7.3 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} From d50644258ddae32c22b036463e4fcf71974fd3b2 Mon Sep 17 00:00:00 2001 From: Sam Lewis Date: Sat, 12 Mar 2022 09:11:05 -0500 Subject: [PATCH 04/10] Update test bench versions for Laravel compatibility --- .github/workflows/run-tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f43467a..67d69bc 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,6 +9,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] + php: [7.3 8.0] stability: [prefer-stable] include: - laravel: 9.* @@ -18,10 +19,10 @@ jobs: testbench: 6.23 php: 8.0 - laravel: 7.* - testbench: 6.23 + testbench: 5.20.0 php: 7.3 - laravel: 6.* - testbench: 6.23 + testbench: 4.18.0 php: 7.3 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} From 00f710cf38ab8be61c53f05dd1359775dc66e97d Mon Sep 17 00:00:00 2001 From: Sam Lewis Date: Sat, 12 Mar 2022 09:15:14 -0500 Subject: [PATCH 05/10] Update matrix --- .github/workflows/run-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 67d69bc..c0af6bb 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,7 +9,8 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [7.3 8.0] + php: [7.3, 8.0, 8.1] + laravel: [9.*, 8.*, 7.*, 6.*] stability: [prefer-stable] include: - laravel: 9.* From 97ff35a136807937aa56e9d75e8bb7c502b1de95 Mon Sep 17 00:00:00 2001 From: Sam Lewis Date: Sat, 12 Mar 2022 09:16:30 -0500 Subject: [PATCH 06/10] Dont fail fast --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c0af6bb..0567c32 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -6,7 +6,7 @@ jobs: test: runs-on: ${{ matrix.os }} strategy: - fail-fast: true + fail-fast: false matrix: os: [ubuntu-latest] php: [7.3, 8.0, 8.1] From 9637f4a12f8e4a82908001fee519706ef33b9b1b Mon Sep 17 00:00:00 2001 From: Sam Lewis Date: Sat, 12 Mar 2022 09:26:08 -0500 Subject: [PATCH 07/10] Update matrix --- .github/workflows/run-tests.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 0567c32..a1fa225 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,19 +12,22 @@ jobs: php: [7.3, 8.0, 8.1] laravel: [9.*, 8.*, 7.*, 6.*] stability: [prefer-stable] + exclude: + - php: 7.3 + laravel: 9.* + - php: 8.1 + laravel: 7.* + - php: 8.1 + laravel: 6.* include: - laravel: 9.* testbench: 7.* - php: 8.0 - laravel: 8.* testbench: 6.23 - php: 8.0 - laravel: 7.* testbench: 5.20.0 - php: 7.3 - laravel: 6.* testbench: 4.18.0 - php: 7.3 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} From fa5b06fa88d2a44ad7b0c56eb1af473e16294712 Mon Sep 17 00:00:00 2001 From: Sam Lewis Date: Sat, 12 Mar 2022 10:32:57 -0500 Subject: [PATCH 08/10] Fix styleci issue --- src/Drivers/Log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Drivers/Log.php b/src/Drivers/Log.php index 7391bf5..60af1e4 100644 --- a/src/Drivers/Log.php +++ b/src/Drivers/Log.php @@ -19,7 +19,7 @@ public function processLog(MessageSent $event) return; } - if(app()->version() >= 9) { + if (app()->version() >= 9) { $message = $event->sent->toString(); } else { $message = $event->message; From 32479ce1fb1547b92d14a2a3225fe7602bbc82a1 Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Tue, 20 Dec 2022 09:07:37 +0100 Subject: [PATCH 09/10] Update Log.php --- src/Drivers/Log.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Drivers/Log.php b/src/Drivers/Log.php index 60af1e4..e27044a 100644 --- a/src/Drivers/Log.php +++ b/src/Drivers/Log.php @@ -19,11 +19,7 @@ public function processLog(MessageSent $event) return; } - if (app()->version() >= 9) { - $message = $event->sent->toString(); - } else { - $message = $event->message; - } + $message = version_compare(app()->version(), '9.0.0', '>') ? $event->sent->toString() : $event->message; /** @var InboundEmail $modelClass */ $modelClass = config('mailbox.model'); From 7f57fab43342d5126aa3d9931ea19476da2bb7b9 Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Tue, 20 Dec 2022 09:08:49 +0100 Subject: [PATCH 10/10] Update InboundEmail.php --- src/InboundEmail.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/InboundEmail.php b/src/InboundEmail.php index 5bfe6d4..089bb02 100644 --- a/src/InboundEmail.php +++ b/src/InboundEmail.php @@ -149,18 +149,20 @@ public function message(): MimeMessage public function reply(Mailable $mailable) { if ($mailable instanceof \Illuminate\Mail\Mailable) { - if (app()->version() >= 9) { - $mailable->withSwiftMessage(function (\Swift_Message $message) { - $message->getHeaders()->addIdHeader('In-Reply-To', $this->id()); + $usesSymfonyMailer = version_compare(app()->version(), '9.0.0', '>'); + + if ($usesSymfonyMailer) { + $mailable->withSymfonyMessage(function (\Symfony\Component\Mime\Email $email) { + $email->getHeaders()->addIdHeader('In-Reply-To', $this->id()); }); } else { - $mailable->withSymfonyMessage(function (\Swift_Message $message) { + $mailable->withSwiftMessage(function (\Swift_Message $message) { $message->getHeaders()->addIdHeader('In-Reply-To', $this->id()); }); } } - return Mail::to($this->from())->send($mailable); + return Mail::to($this->headerValue('Reply-To') ?: $this->from())->send($mailable); } public function forward($recipients)