zendframework / zend-mail

Mail component from Zend Framework
BSD 3-Clause "New" or "Revised" License
96 stars 111 forks source link

Throwing email invalid exception on the email from field of emails being read from an IMAP server #248

Open ibindoff opened 5 years ago

ibindoff commented 5 years ago

I am attempting to read bounced emails and mark the address as bouncy.

Code to reproduce the issue

        //connect to the mail server
        $mail = new Imap([
            'host'     => 'REDACTED',
            'port'     => '993',
            'user'     => 'REDACTED',
            'password' => 'REDACTED',
            'ssl'      => 'SSL'
        ]);

        //open the bounced folder
        $folder = $mail->getFolders()->Bounced;
        $mail->selectFolder($folder);

        //will throw an Exception: The input is not a valid email address. Use the basic format local-part@hostname /vendor/zendframework/zend-mail/src/Address.php 77 if it encounters an email from "MAILER-DAEMON@messagingengine.com" - it will wrongly interpret the email address as simply "MAILER-DAEMON"
        foreach ($mail as $messageNum => $message) {
        }

Expected results

When trying to parse a fairly standard bounced email that comes from MAILER-DAEMON@messagingengine.com it will throw an exception stating that MAILER-DAEMON is not a valid email address.

I suppose it should parse the email from address properly... or perhaps it should have an option to ignore these types of exceptions - since we are not constructing an email, and are simply parsing an email that exists on an actual email server it doesn't make much sense to throw an interrupting exception stating that the email is invalid, when it is in fact a real email that exists on a real mailserver. Since the exception is encountered during a foreach iteration it's not even an option to simply catch and ignore the exception.

Actual results

Exception: The input is not a valid email address. Use the basic format local-part@hostname /vendor/zendframework/zend-mail/src/Address.php 77

weierophinney commented 4 years ago

This repository has been closed and moved to laminas/laminas-mail; a new issue has been opened at https://github.com/laminas/laminas-mail/issues/4.