Skip to content

Commit 7f57fab

Browse files
authored
Update InboundEmail.php
1 parent 32479ce commit 7f57fab

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/InboundEmail.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,20 @@ public function message(): MimeMessage
149149
public function reply(Mailable $mailable)
150150
{
151151
if ($mailable instanceof \Illuminate\Mail\Mailable) {
152-
if (app()->version() >= 9) {
153-
$mailable->withSwiftMessage(function (\Swift_Message $message) {
154-
$message->getHeaders()->addIdHeader('In-Reply-To', $this->id());
152+
$usesSymfonyMailer = version_compare(app()->version(), '9.0.0', '>');
153+
154+
if ($usesSymfonyMailer) {
155+
$mailable->withSymfonyMessage(function (\Symfony\Component\Mime\Email $email) {
156+
$email->getHeaders()->addIdHeader('In-Reply-To', $this->id());
155157
});
156158
} else {
157-
$mailable->withSymfonyMessage(function (\Swift_Message $message) {
159+
$mailable->withSwiftMessage(function (\Swift_Message $message) {
158160
$message->getHeaders()->addIdHeader('In-Reply-To', $this->id());
159161
});
160162
}
161163
}
162164

163-
return Mail::to($this->from())->send($mailable);
165+
return Mail::to($this->headerValue('Reply-To') ?: $this->from())->send($mailable);
164166
}
165167

166168
public function forward($recipients)

0 commit comments

Comments
 (0)