Webklex / php-imap

PHP-IMAP is a wrapper for common IMAP communication without the need to have the php-imap module installed / enabled. The protocol is completely integrated and therefore supports IMAP IDLE operation and the "new" oAuth authentication process as well.
https://www.php-imap.com
MIT License
321 stars 151 forks source link

Undeliverable message report error "Unknown: Unexpected characters at end of address" #462

Open bjaverhagen opened 11 months ago

bjaverhagen commented 11 months ago

Describe the bug When i load an underliverable message report (contenttype = multipart/report), I get the following error "Unknown: Unexpected characters at end of address: postmaster@webhostingserver.nl (errflg=3)".

The error shown at the beginning of part 2 of the textbody.

$message->getFrom(); shown the email as "postmaster@webhostingserver.nl, " instead of "postmaster@webhostingserver.nl".

Used config

'options' => [
        'delimiter' => '.',
        'fetch' => \Webklex\PHPIMAP\IMAP::FT_PEEK,
        'sequence' => \Webklex\PHPIMAP\IMAP::ST_UID,
        'fetch_body' => true,
        'fetch_flags' => true,
        'soft_fail' => false,
        'rfc822' => true,
        'debug' => false,
        'uid_cache' => true,
        'fallback_date' => "01.01.1970 00:00:00",
        'boundary' => '/boundary=(.*?(?=;)|(.*))/i',
        'message_key' => 'list',
        'fetch_order' => 'desc',
        'dispositions' => ['attachment', 'inline'],
        'common_folders' => [
            "root" => "INBOX",
            "junk" => "INBOX.Junk",
            "draft" => "INBOX.Draft",
            "sent" => "INBOX.Sent",
            "trash" => "INBOX.Trash",
        ],
        'decoder' => [
            'message' => 'utf-8', // mimeheader
            'attachment' => 'utf-8' // mimeheader
        ],
        'open' => [
            // 'DISABLE_AUTHENTICATOR' => 'GSSAPI'
        ]

Code to Reproduce

$message = $folder->messages()->getMessageByUid($uid = $_GET['uid']);
echo $message->getTextBody();

Additional context The header of the message report:

Array
(
    [uid] => 3672
    [msgn] => 
    [msglist] => 
    [from] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => from
            [values:protected] => Array
                (
                    [0] => Webklex\PHPIMAP\Address Object
                        (
                            [personal] => 
                            [mailbox] => postmaster
                            [host] => webhostingserver.nl
                            [mail] => postmaster@webhostingserver.nl
                            [full] => postmaster@webhostingserver.nl
                        )

                    [1] => Webklex\PHPIMAP\Address Object
                        (
                            [personal] => 
                            [mailbox] => 
                            [host] => 
                            [mail] => 
                            [full] => 
                        )

                )

        )

    [to] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => to
            [values:protected] => Array
                (
                    [0] => Webklex\PHPIMAP\Address Object
                        (
                            [personal] => 
                            [mailbox] => xxxxx
                            [host] => xxxxx
                            [mail] => xxxxx
                            [full] => xxxxx
                        )

                )

        )

    [reply_to] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => reply_to
            [values:protected] => Array
                (
                    [0] => Webklex\PHPIMAP\Address Object
                        (
                            [personal] => 
                            [mailbox] => postmaster
                            [host] => webhostingserver.nl
                            [mail] => postmaster@webhostingserver.nl
                            [full] => postmaster@webhostingserver.nl
                        )

                    [1] => Webklex\PHPIMAP\Address Object
                        (
                            [personal] => 
                            [mailbox] => 
                            [host] => 
                            [mail] => 
                            [full] => 
                        )

                )

        )

    [sender] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => sender
            [values:protected] => Array
                (
                    [0] => Webklex\PHPIMAP\Address Object
                        (
                            [personal] => 
                            [mailbox] => postmaster
                            [host] => webhostingserver.nl
                            [mail] => postmaster@webhostingserver.nl
                            [full] => postmaster@webhostingserver.nl
                        )

                    [1] => Webklex\PHPIMAP\Address Object
                        (
                            [personal] => 
                            [mailbox] => 
                            [host] => 
                            [mail] => 
                            [full] => 
                        )

                )

        )

    [subject] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => subject
            [values:protected] => Array
                (
                    [0] => Undeliverable: Bedankt voor je email aan Lunchcafe Toren4
                )

        )

    [references] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => references
            [values:protected] => Array
                (
                    [0] => E1rDTgZ-0000000GHRt-1XGS@s202.webhostingserver.nl
                )

        )

    [message_id] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => message_id
            [values:protected] => Array
                (
                    [0] => 946f32b5-99e2-11ee-898a-001a4a4cb933@mailfilter05-out31.webhostingserver.nl
                )

        )

    [in_reply_to] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => in_reply_to
            [values:protected] => Array
                (
                    [0] => E1rDTgZ-0000000GHRt-1XGS@s202.webhostingserver.nl
                )

        )

    [date] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => date
            [values:protected] => Array
                (
                    [0] => Carbon\Carbon Object
                        (
                            [endOfTime:protected] => 
                            [startOfTime:protected] => 
                            [constructedObjectId:protected] => 00000000000000280000000000000000
                            [localMonthsOverflow:protected] => 
                            [localYearsOverflow:protected] => 
                            [localStrictModeEnabled:protected] => 
                            [localHumanDiffOptions:protected] => 
                            [localToStringFormat:protected] => 
                            [localSerializer:protected] => 
                            [localMacros:protected] => 
                            [localGenericMacros:protected] => 
                            [localFormatFunction:protected] => 
                            [localTranslator:protected] => 
                            [dumpProperties:protected] => Array
                                (
                                    [0] => date
                                    [1] => timezone_type
                                    [2] => timezone
                                )

                            [dumpLocale:protected] => 
                            [dumpDateProperties:protected] => 
                            [date] => 2023-12-13 19:08:12.000000
                            [timezone_type] => 1
                            [timezone] => +01:00
                        )

                )

        )

    [return_path] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => return_path
            [values:protected] => Array
                (
                    [0] => <> <>
                )

        )

    [delivered_to] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => delivered_to
            [values:protected] => Array
                (
                    [0] => xxxxx
                )

        )

    [received] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => received
            [values:protected] => Array
                (
                    [0] => from s202.webhostingserver.nl by s202.webhostingserver.nl with LMTP id aNfQMI3zeWX6PiUAqS+bIA (envelope-from <>) for ; Wed, 13 Dec 2023 19:10:21 +0100
                    [1] => from mail by s202.webhostingserver.nl with spam-scanned (Exim 4.97) id 1rDTgb-0000000GHg7-0f6y for xxxxx; Wed, 13 Dec 2023 19:10:21 +0100
                    [2] => from bouncer.webhostingserver.nl ([2a03:3c00:1337:2053::1]) by s202.webhostingserver.nl with esmtps  (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.97) id 1rDTgb-0000000GHeK-0QzI for xxxxx; Wed, 13 Dec 2023 19:10:21 +0100
                    [3] => from mailfilter05-out20.webhostingserver.nl (mailfilter05-out20.webhostingserver.nl [195.211.72.70]) by bouncer.webhostingserver.nl (Postfix) with ESMTPS id A94CE2165D81 for ; Wed, 13 Dec 2023 19:10:20 +0100 (CET)
                    [4] => from s202.webhostingserver.nl by s202.webhostingserver.nl with LMTP id aNfQMI3zeWX6PiUAqS+bIA (envelope-from <>) for 
                )

        )

    [envelope_to] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => envelope_to
            [values:protected] => Array
                (
                    [0] => xxxxx
                )

        )

    [delivery_date] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => delivery_date
            [values:protected] => Array
                (
                    [0] => Wed, 13 Dec 2023 19:10:21 +0100
                )

        )

    [x_spam_checker_version] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => x_spam_checker_version
            [values:protected] => Array
                (
                    [0] => SpamAssassin 3.4.6 (2021-04-09) on s202.webhostingserver.nl
                )

        )

    [x_spam_level] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => x_spam_level
            [values:protected] => Array
                (
                    [0] => 
                )

        )

    [x_spam_status] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => x_spam_status
            [values:protected] => Array
                (
                    [0] => No, score=-0.7 required=10.0 tests=ANTAGONIST_FCHECK1, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6
                )

        )

    [x_spam_report] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => x_spam_report
            [values:protected] => Array
                (
                    [0] => *  0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was *      blocked.  See *      http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block *      for more information. *      [URIs: webhostingserver.nl] * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, *       low trust *      [2a03:3c00:1337:2053:0:0:0:1 listed in] [list.dnswl.org] *  0.0 ANTAGONIST_FCHECK1 Not antagonist.nl sender * -0.0 SPF_HELO_PASS SPF: HELO matches SPF record * -0.0 SPF_PASS SPF: sender matches SPF record * -0.0 T_SCC_BODY_TEXT_LINE No description available.
                )

        )

    [authentication_results] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => authentication_results
            [values:protected] => Array
                (
                    [0] => webhostingserver.nl; iprev=pass (bouncer.webhostingserver.nl) smtp.remote-ip=2a03:3c00:1337:2053::1; spf=pass smtp.helo=bouncer.webhostingserver.nl; dmarc=skipped; arc=none
                    [1] => webhostingserver.nl
                )

        )

    [received_spf] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => received_spf
            [values:protected] => Array
                (
                    [0] => pass (s202.webhostingserver.nl: domain of bouncer.webhostingserver.nl designates 2a03:3c00:1337:2053::1 as permitted sender) client-ip=2a03:3c00:1337:2053::1; envelope-from=postmaster@bouncer.webhostingserver.nl; helo=bouncer.webhostingserver.nl;
                    [1] => pass (s202.webhostingserver.nl: domain of bouncer.webhostingserver.nl designates 2a03:3c00:1337:2053::1 as permitted sender) client-ip=2a03:3c00:1337:2053::1
                )

        )

    [auto_submitted] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => auto_submitted
            [values:protected] => Array
                (
                    [0] => auto-replied
                )

        )

    [mime_version] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => mime_version
            [values:protected] => Array
                (
                    [0] => 1.0
                )

        )

    [content_type] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => content_type
            [values:protected] => Array
                (
                    [0] => multipart/report; report-type=delivery-status; boundary="946f32b5-99e2-11ee-898a-001a4a4cb933"
                    [1] => multipart/report
                )

        )

    [x_sendinguser] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => x_sendinguser
            [values:protected] => Array
                (
                    [0] => unknown
                )

        )

    [x_sendingserver] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => x_sendingserver
            [values:protected] => Array
                (
                    [0] => s202.webhostingserver.nl
                )

        )

    [x_antivirus_scanner] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => x_antivirus_scanner
            [values:protected] => Array
                (
                    [0] => Clean mail though you should still use an Antivirus
                )

        )

    [toaddress] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => toaddress
            [values:protected] => Array
                (
                    [0] => xxxxx
                )

        )

    [fromaddress] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => fromaddress
            [values:protected] => Array
                (
                    [0] => postmaster@webhostingserver.nl, UNEXPECTED_DATA_AFTER_ADDRESS@".SYNTAX-ERROR."
                )

        )

    [reply_toaddress] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => reply_toaddress
            [values:protected] => Array
                (
                    [0] => postmaster@webhostingserver.nl, UNEXPECTED_DATA_AFTER_ADDRESS@".SYNTAX-ERROR."
                )

        )

    [senderaddress] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => senderaddress
            [values:protected] => Array
                (
                    [0] => postmaster@webhostingserver.nl, UNEXPECTED_DATA_AFTER_ADDRESS@".SYNTAX-ERROR."
                )

        )

    [iprev] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => iprev
            [values:protected] => Array
                (
                    [0] => pass (bouncer.webhostingserver.nl) smtp.remote-ip=2a03:3c00:1337:2053::1
                )

        )

    [spf] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => spf
            [values:protected] => Array
                (
                    [0] => pass smtp.helo=bouncer.webhostingserver.nl
                )

        )

    [dmarc] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => dmarc
            [values:protected] => Array
                (
                    [0] => skipped
                )

        )

    [arc] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => arc
            [values:protected] => Array
                (
                    [0] => none
                )

        )

    [envelope-from] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => envelope-from
            [values:protected] => Array
                (
                    [0] => postmaster@bouncer.webhostingserver.nl
                )

        )

    [helo] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => helo
            [values:protected] => Array
                (
                    [0] => bouncer.webhostingserver.nl
                )

        )

    [report-type] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => report-type
            [values:protected] => Array
                (
                    [0] => delivery-status
                )

        )

    [boundary] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => boundary
            [values:protected] => Array
                (
                    [0] => 946f32b5-99e2-11ee-898a-001a4a4cb933
                )

        )

    [priority] => Webklex\PHPIMAP\Attribute Object
        (
            [name:protected] => priority
            [values:protected] => Array
                (
                    [0] => 0
                )

        )

)
bjaverhagen commented 1 month ago

Can someone help me with this error?