Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.0' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanjeev Papnoi committed Jun 19, 2021
2 parents b6a1c85 + d72df5c commit f9e5b5b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Services/MailboxService.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ public function getMailboxByEmail($email)

throw new \Exception("No mailbox found for email '$email'");
}

public function getMailboxByToEmail($email)
{
foreach ($this->getRegisteredMailboxes() as $registeredMailbox) {
if ($email === $registeredMailbox['imap_server']['username']) {
return true;
}
}

return false;
}

private function searchticketSubjectRefrence($senderEmail, $messageSubject) {

Expand Down Expand Up @@ -302,9 +313,15 @@ public function processMail($rawEmail)
// An exception being thrown means no mailboxes were found from the recipient's address. Continue processing.
}
}

foreach($addresses['to'] as $mailboxEmail){
if($this->getMailboxByToEmail(strtolower($mailboxEmail))){
$mailData['replyTo'] = $mailboxEmail;
}
}

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

return;
}
}
}

0 comments on commit f9e5b5b

Please sign in to comment.