uvdesk / mailbox-component

The Mailbox component provides tools that allows your helpdesk to process tickets from multiple email sources.
MIT License
22 stars 38 forks source link

MailboxService.php: ErrorException thrown Notice: Undefined index: replyTo on lien 325 #89

Closed silviuchingaru closed 2 years ago

silviuchingaru commented 2 years ago

If mailbox (ex uvd-office@example.org) is part of a forward list (ex: office@example.org), the following check fails:

MailboxService::processMail($rawEmail) {
// ...
foreach ($addresses['to'] as $mailboxEmail) {
  if ($this->getMailboxByToEmail(strtolower($mailboxEmail))) {
    $mailData['replyTo'] = $mailboxEmail;
  }
}

// Process Mail - References
$addresses['to'][0] = strtolower($mailData['replyTo']) ?? strtolower($addresses['to'][0]);
// ...

ErrorException with message "Notice: Undefined index: replyTo" on line 325 is thrown because $mailData['replyTo'] is not set and when strtolower() is called, error is throwed and further processing of the message is halted.

Proposed solution:

MailboxService::processMail($rawEmail) {
// ...
$mailData['replyTo'] = ''; // Set replyTo empty by default to prevent the error.
foreach ($addresses['to'] as $mailboxEmail) {
  if ($this->getMailboxByToEmail(strtolower($mailboxEmail))) {
    $mailData['replyTo'] = $mailboxEmail;
  }
}

// Process Mail - References
$addresses['to'][0] = strtolower($mailData['replyTo']) ?? strtolower($addresses['to'][0]);
// ...
silviuchingaru commented 2 years ago

It seems #85 and #86 are also related to this.