Subscribe Newsletter

Your Name  : 
Email Address *  : 
  • Online: Get Electricity Bill Now on Mobile and Email | Bala-Krishna
  • webs.com: com and type in the IP address you want to convert into its decimal url,...
  • PNR Status: check multiple pnr status with a single click PNR Status
  • Click here: Cheers for the informative blog post, I truly appreciated it. I would...
  • Leela: Only site on web which allows checking of Multiple Train PNR Status with a...
  • PUNEET: getting authentication error in digsby while opening yahoo email accounts,...
  • Arvind Pandit: Search your bank SWIFT code online | Bala-Krishna
  • pokemon: Wordpress WP_Categories doesn?t exist Error Fix | Bala-Krishna
  • Jambula Hanmanth Reddy: SIR/MADAM, I have forgot my username,password,and...
  • Jitendrakumar: This is working Perfectly. Thanks Buddy
  • ashfaq: nice post it well me lot no 1 has solution for this problem
  • irctc pnr status: This is useful information to know the pnr status. Thanks for...
  • Maria: How? How do you change the Digsby default yahoo server to the new one?...
  • 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