diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..a1fa225 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,57 @@ +name: run-tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + 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.* + - laravel: 8.* + testbench: 6.23 + - laravel: 7.* + testbench: 5.20.0 + - laravel: 6.* + testbench: 4.18.0 + + 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..e27044a 100644 --- a/src/Drivers/Log.php +++ b/src/Drivers/Log.php @@ -19,9 +19,11 @@ public function processLog(MessageSent $event) return; } + $message = version_compare(app()->version(), '9.0.0', '>') ? $event->sent->toString() : $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..089bb02 100644 --- a/src/InboundEmail.php +++ b/src/InboundEmail.php @@ -149,12 +149,20 @@ 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()); - }); + $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->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)