Skip to content

Commit f9e5b5b

Browse files
author
Sanjeev Papnoi
committed
Merge remote-tracking branch 'origin/1.0' into HEAD
2 parents b6a1c85 + d72df5c commit f9e5b5b

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Services/MailboxService.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ public function getMailboxByEmail($email)
167167

168168
throw new \Exception("No mailbox found for email '$email'");
169169
}
170+
171+
public function getMailboxByToEmail($email)
172+
{
173+
foreach ($this->getRegisteredMailboxes() as $registeredMailbox) {
174+
if ($email === $registeredMailbox['imap_server']['username']) {
175+
return true;
176+
}
177+
}
178+
179+
return false;
180+
}
170181

171182
private function searchticketSubjectRefrence($senderEmail, $messageSubject) {
172183

@@ -302,9 +313,15 @@ public function processMail($rawEmail)
302313
// An exception being thrown means no mailboxes were found from the recipient's address. Continue processing.
303314
}
304315
}
316+
317+
foreach($addresses['to'] as $mailboxEmail){
318+
if($this->getMailboxByToEmail(strtolower($mailboxEmail))){
319+
$mailData['replyTo'] = $mailboxEmail;
320+
}
321+
}
305322

306323
// Process Mail - References
307-
$addresses['to'][0] = strtolower($addresses['to'][0]);
324+
$addresses['to'][0] = strtolower($mailData['replyTo']) ?? strtolower($addresses['to'][0]);
308325
$mailData['replyTo'] = $addresses['to'];
309326
$mailData['messageId'] = $parser->getHeader('message-id') ?: null;
310327
$mailData['inReplyTo'] = htmlspecialchars_decode($parser->getHeader('in-reply-to'));
@@ -439,4 +456,4 @@ public function processMail($rawEmail)
439456

440457
return;
441458
}
442-
}
459+
}

0 commit comments

Comments
 (0)