zend-mail icon indicating copy to clipboard operation
zend-mail copied to clipboard

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

Open ibindoff opened this issue 6 years ago • 1 comments

  • [X] I was not able to find an open or closed issue matching what I'm seeing.
  • [X] This is not a question. (Questions should be asked on chat (Signup here) or our forums.)

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 "[email protected]" - 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 [email protected] 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

ibindoff avatar Nov 06 '19 02:11 ibindoff

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.

weierophinney avatar Dec 31 '19 21:12 weierophinney