Yep, just another open source software errors I’ve got.
In my situation, I was using news-mailer plugin for wordpress, as I needed to send some mails to all registered users. While testing this plugin with my email, everything went ok, but as soon as I tried sending email to all users, I’ve got this error:
Fatal error: Uncaught exception ‘Swift_RfcComplianceException’ with message ‘Address in mailbox given [some@email] does not comply with RFC 2822
Yes, some of the emails list were not compatible with RFC2822. So what? I needed to send emails anyway. There are several ways of solution of this problem. File causing problems was:
wp-content/plugins/news-mailer/swift/lib/classes/Swift/Mime/Headers/MailboxHeader.php
As you can see, this plugin uses Swift mailer.
First of if, I could manually verify every email passed to emailer. Emails passed as an array list. But… I needed solution right now. So I made it simple way:
in fhe file mentioned above (MailboxHeader.php) I modified function
private function _assertValidAddress($address) { return; /* Fix; skipping email format RFC2822 check */ if (!preg_match('/^' . $this->getGrammar('addr-spec') . '$/D', $address)) { throw new Swift_RfcComplianceException( 'Address in mailbox given [' . $address . '] does not comply with RFC 2822, 3.6.2.' ); } }
As you see, I just added one line. I could comment entire code, or just remove it. But I wanted to leave original code, if I will use another fix. Well, I don’t plan to do that
As I mentioned, I would prefer another fixes: validate each email in array, or instead of throw new Swift_RfcComplianceException, I would like to suspend that user, or remove him, or send warning message. Anyway. I needed couple minutes fix, so made it easy way.
I hope this will help for some webmasters, who needed a quick solution.
