Subscribe Newsletter

Your Name  : 
Email Address *  : 
  • PNR Enquiry: Google SMS is a good way but besides it you can also check the PNR...
  • ???????: Thanks a lot, I have same problem and think how to solve it all day,...
  • Union Budget 2013-2014: Nice service by Indian Railways.
  • Railway Budget 2013: It is nice service of Google SMS by Indian Railway.
  • wordpress – widgets – plugin 2012: For more information see:...
  • PNR Status: thank you for the info
  • louisg: Thank you Bala Krishna, that’s very nice. Thanks for the SEO plug as...
  • Sandeep Beniwal: Hi, I want to convert video into .flv/.swf using asp.net...
  • Barun Roy Choudhury: Please send me swift code for IOB Santoshpur branch Kolkata...
  • Daniel: Hi, I followed the steps in the article and it gives me an error: Unknown...
  • amarana mohanarao: hello sir iam mohan plz send me STATEBANK OF INDIA [kotturu]...
  • Irina: Hi! Thank you for the article, really nice, but I have some more question...
  • s khaja mynuddin: hello i have forgotten my profile password can i send the filled...
  • Archives

  • Blog Stats

How to Fix Swift Mailer Error Address in mailbox given does not comply with RFC

Swift Mailer is an robust object oriented library written in PHP5 with lot of useful features. It can be used with any PHP application developed in PHP5. Symfony, Typo3 framework as well as many other open source framework uses this library. The error i am talking about seems to be a common error and lot of people talking on the web about it. I personally encountered this error with Symfony framework when i was trying to send an email to user after registration. The script thrown following error:

Fatal error: Uncaught exception ‘Swift_RfcComplianceException’ with message ‘Address in mailbox given [] does not comply with RFC 2822, 3.6.2.’ in

The exception itself says there is something wrong in email address fields such as From, Sender or Reply-To fields. Swift Mailer strictly follow RFC standard to avoid emails being caught by spam checker tools. There are following reason can lead to this error.

  • Incorrect email address format in to,from or reply-to fields
  • Email address or host does not exist
  • From email address should be valid working email address
  • Not fully qualified domain name used in from email address

To fix this error check above settings in you script and fix accordingly. You may need to check RFC standard to fix this error. If still does not fix error you can disable email address RFC standard checking code in swift mailer script. Obviously this is not recommended but some time developer need to apply fix temporarily.

Before applying please check Swift Mailer documentation on how to set To,From,Cc, Bcc, Reply To fields correctly in Swift Mailer.

How To Disable RFC Standard Check

Go to swiftmailer\classes\Swift\Mime\Headers folder and open MailboxHeader.php file in editor. Go to line number 304 and comment throw exception line as specified below.

For Symfony users: swift mailer library can be found in vendor folder.

private function _assertValidAddress($address)
{
  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.'
    //  );
  }
}

The error should be disappear now.


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply