Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
weierophinney opened this issue Dec 31, 2019 · 1 comment

Comments

@weierophinney
Copy link
Member

  • I was not able to find an open or closed issue matching what I'm seeing.
  • 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 "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


Originally posted by @ibindoff at zendframework/zend-mail#248

@abulhol
Copy link
Contributor

abulhol commented Aug 9, 2024

I get the same error due to a To: header that looks like this:
To: Undisclosed@xyz.default, recipients:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants