Skip to content

Commit

Permalink
Merge pull request #1913 from GabrielBragaGit/patch-5
Browse files Browse the repository at this point in the history
Undefined array key 'from' error when processing certain emails
  • Loading branch information
devansh-webkul authored Jan 10, 2025
2 parents f6478e4 + b79722c commit 0bddcbf
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/Webkul/Email/src/Helpers/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,20 @@ public function getMessageBody($type = 'text')
$textBody .= $this->decodeContentTransfer($this->getPartBody($part), $encodingType);
$textBody = nl2br($this->charset->decodeCharset($textBody, $this->getPartCharset($part)));
} elseif ($this->getPart('content-type', $part) == 'text/plain; (error)') {
$part_from_sender = is_array($part['headers']['from']) ? $part['headers']['from'][0] : $part['headers']['from'];
if (empty($part['headers']) || !isset($part['headers']['from'])) {
$parentKey = explode('.', $key)[0];
if (isset($this->parts[$parentKey]) && isset($this->parts[$parentKey]['headers']['from'])) {
$part_from_sender = is_array($this->parts[$parentKey]['headers']['from'])
? $this->parts[$parentKey]['headers']['from'][0]
: $this->parts[$parentKey]['headers']['from'];
} else {
continue;
}
} else {
$part_from_sender = is_array($part['headers']['from'])
? $part['headers']['from'][0]
: $part['headers']['from'];
}
$mail_part_addresses = mailparse_rfc822_parse_addresses($part_from_sender);

if (! empty($mail_part_addresses[0]['address'])
Expand Down

0 comments on commit 0bddcbf

Please sign in to comment.