title: swift mailer error 'Swift_RfcComplianceException' on an email that actually works?
body: <p>My swift mailer plugin has just thrown up an error because an email address it tried to send to isn't compliant. Problem is - the email is valid.</p>
  
  <p>Basically, I don't want swift mailer to be checking whether or not the email is valid I'd like it send regardless. Is that possible?</p>
  
  <p>here is the code which has the function which displays the error but I don't know if what I would need to change is in here or not (kinda a hack programmer :| )</p>
  
  <pre><code>//@require 'Swift/Mime/Headers/AbstractHeader.php';
  //@require 'Swift/Mime/HeaderEncoder.php';
  
  /**
   * A Mailbox Address MIME Header for something like From or Sender.
   * @package Swift
   * @subpackage Mime
   * @author Chris Corbyn
   */
  class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
  {
  
    /**
     * The mailboxes used in this Header.
     * @var string[]
     * @access private
     */
    private $_mailboxes = array();
  
    /**
     * Creates a new MailboxHeader with $name.
     * @param string $name of Header
     * @param Swift_Mime_HeaderEncoder $encoder
     */
    public function __construct($name, Swift_Mime_HeaderEncoder $encoder)
    {
      $this-&gt;setFieldName($name);
      $this-&gt;setEncoder($encoder);
      $this-&gt;initializeGrammar();
    }
  
    /**
     * Get the type of Header that this instance represents.
     * @return int
     * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
     * @see TYPE_DATE, TYPE_ID, TYPE_PATH
     */
    public function getFieldType()
    {
      return self::TYPE_MAILBOX;
    }
  
    /**
     * Set the model for the field body.
     * This method takes a string, or an array of addresses.
     * @param mixed $model
     * @throws Swift_RfcComplianceException
     */
    public function setFieldBodyModel($model)
    {
      $this-&gt;setNameAddresses($model);
    }
  
    /**
     * Get the model for the field body.
     * This method returns an associative array like {@link getNameAddresses()}
     * @return array
     * @throws Swift_RfcComplianceException
     */
    public function getFieldBodyModel()
    {
      return $this-&gt;getNameAddresses();
    }
  
    /**
     * Set a list of mailboxes to be shown in this Header.
     * The mailboxes can be a simple array of addresses, or an array of
     * key=&gt;value pairs where (email =&gt; personalName).
     * Example:
     * &lt;code&gt;
     * &lt;?php
     * //Sets two mailboxes in the Header, one with a personal name
     * $header-&gt;setNameAddresses(array(
     *  'chris@swiftmailer.org' =&gt; 'Chris Corbyn',
     *  'mark@swiftmailer.org' //No associated personal name
     *  ));
     * ?&gt;
     * &lt;/code&gt;
     * @param string|string[] $mailboxes
     * @throws Swift_RfcComplianceException
     * @see __construct()
     * @see setAddresses()
     * @see setValue()
     */
    public function setNameAddresses($mailboxes)
    {
      $this-&gt;_mailboxes = $this-&gt;normalizeMailboxes((array) $mailboxes);
      $this-&gt;setCachedValue(null); //Clear any cached value
    }
  
    /**
     * Get the full mailbox list of this Header as an array of valid RFC 2822 strings.
     * Example:
     * &lt;code&gt;
     * &lt;?php
     * $header = new Swift_Mime_Headers_MailboxHeader('From',
     *  array('chris@swiftmailer.org' =&gt; 'Chris Corbyn',
     *  'mark@swiftmailer.org' =&gt; 'Mark Corbyn')
     *  );
     * print_r($header-&gt;getNameAddressStrings());
     * // array (
     * // 0 =&gt; Chris Corbyn &lt;chris@swiftmailer.org&gt;,
     * // 1 =&gt; Mark Corbyn &lt;mark@swiftmailer.org&gt;
     * // )
     * ?&gt;
     * &lt;/code&gt;
     * @return string[]
     * @throws Swift_RfcComplianceException
     * @see getNameAddresses()
     * @see toString()
     */
    public function getNameAddressStrings()
    {
      return $this-&gt;_createNameAddressStrings($this-&gt;getNameAddresses());
    }
  
    /**
     * Get all mailboxes in this Header as key=&gt;value pairs.
     * The key is the address and the value is the name (or null if none set).
     * Example:
     * &lt;code&gt;
     * &lt;?php
     * $header = new Swift_Mime_Headers_MailboxHeader('From',
     *  array('chris@swiftmailer.org' =&gt; 'Chris Corbyn',
     *  'mark@swiftmailer.org' =&gt; 'Mark Corbyn')
     *  );
     * print_r($header-&gt;getNameAddresses());
     * // array (
     * // chris@swiftmailer.org =&gt; Chris Corbyn,
     * // mark@swiftmailer.org =&gt; Mark Corbyn
     * // )
     * ?&gt;
     * &lt;/code&gt;
     * @return string[]
     * @see getAddresses()
     * @see getNameAddressStrings()
     */
    public function getNameAddresses()
    {
      return $this-&gt;_mailboxes;
    }
  
    /**
     * Makes this Header represent a list of plain email addresses with no names.
     * Example:
     * &lt;code&gt;
     * &lt;?php
     * //Sets three email addresses as the Header data
     * $header-&gt;setAddresses(
     *  array('one@domain.tld', 'two@domain.tld', 'three@domain.tld')
     *  );
     * ?&gt;
     * &lt;/code&gt;
     * @param string[] $addresses
     * @throws Swift_RfcComplianceException
     * @see setNameAddresses()
     * @see setValue()
     */
    public function setAddresses($addresses)
    {
      return $this-&gt;setNameAddresses(array_values((array) $addresses));
    }
  
    /**
     * Get all email addresses in this Header.
     * @return string[]
     * @see getNameAddresses()
     */
    public function getAddresses()
    {
      return array_keys($this-&gt;_mailboxes);
    }
  
    /**
     * Remove one or more addresses from this Header.
     * @param string|string[] $addresses
     */
    public function removeAddresses($addresses)
    {
      $this-&gt;setCachedValue(null);
      foreach ((array) $addresses as $address)
      {
        unset($this-&gt;_mailboxes[$address]);
      }
    }
  
    /**
     * Get the string value of the body in this Header.
     * This is not necessarily RFC 2822 compliant since folding white space will
     * not be added at this stage (see {@link toString()} for that).
     * @return string
     * @throws Swift_RfcComplianceException
     * @see toString()
     */
    public function getFieldBody()
    {
      //Compute the string value of the header only if needed
      if (is_null($this-&gt;getCachedValue()))
      {
        $this-&gt;setCachedValue($this-&gt;createMailboxListString($this-&gt;_mailboxes));
      }
      return $this-&gt;getCachedValue();
    }
  
    // -- Points of extension
  
    /**
     * Normalizes a user-input list of mailboxes into consistent key=&gt;value pairs.
     * @param string[] $mailboxes
     * @return string[]
     * @access protected
     */
    protected function normalizeMailboxes(array $mailboxes)
    {
      $actualMailboxes = array();
  
      foreach ($mailboxes as $key =&gt; $value)
      {
        if (is_string($key)) //key is email addr
        {
          $address = $key;
          $name = $value;
        }
        else
        {
          $address = $value;
          $name = null;
        }
        $this-&gt;_assertValidAddress($address);
        $actualMailboxes[$address] = $name;
      }
  
      return $actualMailboxes;
    }
  
    /**
     * Produces a compliant, formatted display-name based on the string given.
     * @param string $displayName as displayed
     * @param boolean $shorten the first line to make remove for header name
     * @return string
     * @access protected
     */
    protected function createDisplayNameString($displayName, $shorten = false)
    {
      return $this-&gt;createPhrase($this, $displayName,
        $this-&gt;getCharset(), $this-&gt;getEncoder(), $shorten
        );
    }
  
    /**
     * Creates a string form of all the mailboxes in the passed array.
     * @param string[] $mailboxes
     * @return string
     * @throws Swift_RfcComplianceException
     * @access protected
     */
    protected function createMailboxListString(array $mailboxes)
    {
      return implode(', ', $this-&gt;_createNameAddressStrings($mailboxes));
    }
  
    // -- Private methods
  
    /**
     * Return an array of strings conforming the the name-addr spec of RFC 2822.
     * @param string[] $mailboxes
     * @return string[]
     * @access private
     */
    private function _createNameAddressStrings(array $mailboxes)
    {
      $strings = array();
  
      foreach ($mailboxes as $email =&gt; $name)
      {
        $mailboxStr = $email;
        if (!is_null($name))
        {
          $nameStr = $this-&gt;createDisplayNameString($name, empty($strings));
          $mailboxStr = $nameStr . ' &lt;' . $mailboxStr . '&gt;';
        }
        $strings[] = $mailboxStr;
      }
  
      return $strings;
    }
  
    /**
     * Throws an Exception if the address passed does not comply with RFC 2822.
     * @param string $address
     * @throws Exception If invalid.
     * @access protected
     */
    private function _assertValidAddress($address)
    {
      if (!preg_match('/^' . $this-&gt;getGrammar('addr-spec') . '$/D',
        $address))
      {
        throw new Swift_RfcComplianceException(
          'Address in mailbox given [' . $address .
          '] does not comply with RFC 2822, 3.6.2.'
          );
      }
    }
  
  }
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>note: swiftmailer is working for most email addresses.</p>