Connecting Tech Pros Worldwide Help | Site Map

Geeting error:PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' wit

Newbie
 
Join Date: Oct 2009
Posts: 4
#1: 3 Weeks Ago
I am getting error on signup at
http://makemycreative.in/source/index.php

Quote:
PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' with message 'Address in mailbox given [] does not comply with RFC 2822, 3.6.2.' in C:\HostingSpaces\makemycr\makemycreative.in\wwwroo t\source\inc\php\swift\classes\Swift\Mime\Headers\ MailboxHeader.php:319
Stack trace:
#0 C:\HostingSpaces\makemycr\makemycreative.in\wwwroo t\source\inc\php\swift\classes\Swift\Mime\Headers\ MailboxHeader.php(249): Swift_Mime_Headers_MailboxHeader->_assertValidAddress('')
#1 C:\HostingSpaces\makemycr\makemycreative.in\wwwroo t\source\inc\php\swift\classes\Swift\Mime\Headers\ MailboxHeader.php(107): Swift_Mime_Headers_MailboxHeader->normalizeMailboxes(Array)
#2 C:\HostingSpaces\makemycr\makemycreative.in\wwwroo t\source\inc\php\swift\classes\Swift\Mime\Headers\ MailboxHeader.php(71): Swift_Mime_Headers_MailboxHeader->setNameAddresses(Array)
#3 C:\HostingSpaces\makemycr\makemycreative.in\wwwroo t\source\inc\php\swift\classes\Swift\Mime\SimpleHe aderFactory.php(74): Swift_Mime_Headers_MailboxHeader->setFieldBodyModel(Array)
#4 C:\HostingSpa in C:\HostingSpaces\makemycr\makemycreative.in\wwwroo t\source\inc\php\swift\classes\Swift\Mime\Headers\ MailboxHeader.php on line 319
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: 3 Weeks Ago

re: Geeting error:PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' wit


That's all fine and dandy, but without seeing the code itself we cannot possibly help you.

Mark.
Newbie
 
Join Date: Oct 2009
Posts: 4
#3: 3 Weeks Ago

re: Geeting error:PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' wit


File Name: MailboxHeader.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. /*
  4.  A Mailbox Address Mime Header in Swift Mailer.
  5.  
  6.  This program is free software: you can redistribute it and/or modify
  7.  it under the terms of the GNU General Public License as published by
  8.  the Free Software Foundation, either version 3 of the License, or
  9.  (at your option) any later version.
  10.  
  11.  This program is distributed in the hope that it will be useful,
  12.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  GNU General Public License for more details.
  15.  
  16.  You should have received a copy of the GNU General Public License
  17.  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  
  19.  */
  20.  
  21. //@require 'Swift/Mime/Headers/AbstractHeader.php';
  22. //@require 'Swift/Mime/HeaderEncoder.php';
  23.  
  24. /**
  25.  * A Mailbox Address MIME Header for something like From or Sender.
  26.  * @package Swift
  27.  * @subpackage Mime
  28.  * @author Chris Corbyn
  29.  */
  30. class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
  31. {
  32.  
  33.   /**
  34.    * The mailboxes used in this Header.
  35.    * @var string[]
  36.    * @access private
  37.    */
  38.   private $_mailboxes = array();
  39.  
  40.   /**
  41.    * Creates a new MailboxHeader with $name.
  42.    * @param string $name of Header
  43.    * @param Swift_Mime_HeaderEncoder $encoder
  44.    */
  45.   public function __construct($name, Swift_Mime_HeaderEncoder $encoder)
  46.   {
  47.     $this->setFieldName($name);
  48.     $this->setEncoder($encoder);
  49.     $this->initializeGrammar();
  50.   }
  51.  
  52.   /**
  53.    * Get the type of Header that this instance represents.
  54.    * @return int
  55.    * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
  56.    * @see TYPE_DATE, TYPE_ID, TYPE_PATH
  57.    */
  58.   public function getFieldType()
  59.   {
  60.     return self::TYPE_MAILBOX;
  61.   }
  62.  
  63.   /**
  64.    * Set the model for the field body.
  65.    * This method takes a string, or an array of addresses.
  66.    * @param mixed $model
  67.    * @throws Swift_RfcComplianceException
  68.    */
  69.   public function setFieldBodyModel($model)
  70.   {
  71.     $this->setNameAddresses($model);
  72.   }
  73.  
  74.   /**
  75.    * Get the model for the field body.
  76.    * This method returns an associative array like {@link getNameAddresses()}
  77.    * @return array
  78.    * @throws Swift_RfcComplianceException
  79.    */
  80.   public function getFieldBodyModel()
  81.   {
  82.     return $this->getNameAddresses();
  83.   }
  84.  
  85.   /**
  86.    * Set a list of mailboxes to be shown in this Header.
  87.    * The mailboxes can be a simple array of addresses, or an array of
  88.    * key=>value pairs where (email => personalName).
  89.    * Example:
  90.    * <code>
  91.    * <?php
  92.    * //Sets two mailboxes in the Header, one with a personal name
  93.    * $header->setNameAddresses(array(
  94.    *  'chris@swiftmailer.org' => 'Chris Corbyn',
  95.    *  'mark@swiftmailer.org' //No associated personal name
  96.    *  ));
  97.    * ?>
  98.    * </code>
  99.    * @param string|string[] $mailboxes
  100.    * @throws Swift_RfcComplianceException
  101.    * @see __construct()
  102.    * @see setAddresses()
  103.    * @see setValue()
  104.    */
  105.   public function setNameAddresses($mailboxes)
  106.   {
  107.     $this->_mailboxes = $this->normalizeMailboxes((array) $mailboxes);
  108.     $this->setCachedValue(null); //Clear any cached value
  109.   }
  110.  
  111.   /**
  112.    * Get the full mailbox list of this Header as an array of valid RFC 2822 strings.
  113.    * Example:
  114.    * <code>
  115.    * <?php
  116.    * $header = new Swift_Mime_Headers_MailboxHeader('From',
  117.    *  array('chris@swiftmailer.org' => 'Chris Corbyn',
  118.    *  'mark@swiftmailer.org' => 'Mark Corbyn')
  119.    *  );
  120.    * print_r($header->getNameAddressStrings());
  121.    * // array (
  122.    * // 0 => Chris Corbyn <chris@swiftmailer.org>,
  123.    * // 1 => Mark Corbyn <mark@swiftmailer.org>
  124.    * // )
  125.    * ?>
  126.    * </code>
  127.    * @return string[]
  128.    * @throws Swift_RfcComplianceException
  129.    * @see getNameAddresses()
  130.    * @see toString()
  131.    */
  132.   public function getNameAddressStrings()
  133.   {
  134.     return $this->_createNameAddressStrings($this->getNameAddresses());
  135.   }
  136.  
  137.   /**
  138.    * Get all mailboxes in this Header as key=>value pairs.
  139.    * The key is the address and the value is the name (or null if none set).
  140.    * Example:
  141.    * <code>
  142.    * <?php
  143.    * $header = new Swift_Mime_Headers_MailboxHeader('From',
  144.    *  array('chris@swiftmailer.org' => 'Chris Corbyn',
  145.    *  'mark@swiftmailer.org' => 'Mark Corbyn')
  146.    *  );
  147.    * print_r($header->getNameAddresses());
  148.    * // array (
  149.    * // chris@swiftmailer.org => Chris Corbyn,
  150.    * // mark@swiftmailer.org => Mark Corbyn
  151.    * // )
  152.    * ?>
  153.    * </code>
  154.    * @return string[]
  155.    * @see getAddresses()
  156.    * @see getNameAddressStrings()
  157.    */
  158.   public function getNameAddresses()
  159.   {
  160.     return $this->_mailboxes;
  161.   }
  162.  
  163.   /**
  164.    * Makes this Header represent a list of plain email addresses with no names.
  165.    * Example:
  166.    * <code>
  167.    * <?php
  168.    * //Sets three email addresses as the Header data
  169.    * $header->setAddresses(
  170.    *  array('one@domain.tld', 'two@domain.tld', 'three@domain.tld')
  171.    *  );
  172.    * ?>
  173.    * </code>
  174.    * @param string[] $addresses
  175.    * @throws Swift_RfcComplianceException
  176.    * @see setNameAddresses()
  177.    * @see setValue()
  178.    */
  179.   public function setAddresses($addresses)
  180.   {
  181.     return $this->setNameAddresses(array_values((array) $addresses));
  182.   }
  183.  
  184.   /**
  185.    * Get all email addresses in this Header.
  186.    * @return string[]
  187.    * @see getNameAddresses()
  188.    */
  189.   public function getAddresses()
  190.   {
  191.     return array_keys($this->_mailboxes);
  192.   }
  193.  
  194.   /**
  195.    * Remove one or more addresses from this Header.
  196.    * @param string|string[] $addresses
  197.    */
  198.   public function removeAddresses($addresses)
  199.   {
  200.     $this->setCachedValue(null);
  201.     foreach ((array) $addresses as $address)
  202.     {
  203.       unset($this->_mailboxes[$address]);
  204.     }
  205.   }
  206.  
  207.   /**
  208.    * Get the string value of the body in this Header.
  209.    * This is not necessarily RFC 2822 compliant since folding white space will
  210.    * not be added at this stage (see {@link toString()} for that).
  211.    * @return string
  212.    * @throws Swift_RfcComplianceException
  213.    * @see toString()
  214.    */
  215.   public function getFieldBody()
  216.   {
  217.     //Compute the string value of the header only if needed
  218.     if (is_null($this->getCachedValue()))
  219.     {
  220.       $this->setCachedValue($this->createMailboxListString($this->_mailboxes));
  221.     }
  222.     return $this->getCachedValue();
  223.   }
  224.  
  225.   // -- Points of extension
  226.  
  227.   /**
  228.    * Normalizes a user-input list of mailboxes into consistent key=>value pairs.
  229.    * @param string[] $mailboxes
  230.    * @return string[]
  231.    * @access protected
  232.    */
  233.   protected function normalizeMailboxes(array $mailboxes)
  234.   {
  235.     $actualMailboxes = array();
  236.  
  237.     foreach ($mailboxes as $key => $value)
  238.     {
  239.       if (is_string($key)) //key is email addr
  240.       {
  241.         $address = $key;
  242.         $name = $value;
  243.       }
  244.       else
  245.       {
  246.         $address = $value;
  247.         $name = null;
  248.       }
  249.       $this->_assertValidAddress($address);
  250.       $actualMailboxes[$address] = $name;
  251.     }
  252.  
  253.     return $actualMailboxes;
  254.   }
  255.  
  256.   /**
  257.    * Produces a compliant, formatted display-name based on the string given.
  258.    * @param string $displayName as displayed
  259.    * @param boolean $shorten the first line to make remove for header name
  260.    * @return string
  261.    * @access protected
  262.    */
  263.   protected function createDisplayNameString($displayName, $shorten = false)
  264.   {
  265.     return $this->createPhrase($this, $displayName,
  266.       $this->getCharset(), $this->getEncoder(), $shorten
  267.       );
  268.   }
  269.  
  270.   /**
  271.    * Creates a string form of all the mailboxes in the passed array.
  272.    * @param string[] $mailboxes
  273.    * @return string
  274.    * @throws Swift_RfcComplianceException
  275.    * @access protected
  276.    */
  277.   protected function createMailboxListString(array $mailboxes)
  278.   {
  279.     return implode(', ', $this->_createNameAddressStrings($mailboxes));
  280.   }
  281.  
  282.   // -- Private methods
  283.  
  284.   /**
  285.    * Return an array of strings conforming the the name-addr spec of RFC 2822.
  286.    * @param string[] $mailboxes
  287.    * @return string[]
  288.    * @access private
  289.    */
  290.   private function _createNameAddressStrings(array $mailboxes)
  291.   {
  292.     $strings = array();
  293.  
  294.     foreach ($mailboxes as $email => $name)
  295.     {
  296.       $mailboxStr = $email;
  297.       if (!is_null($name))
  298.       {
  299.         $nameStr = $this->createDisplayNameString($name, empty($strings));
  300.         $mailboxStr = $nameStr . ' <' . $mailboxStr . '>';
  301.       }
  302.       $strings[] = $mailboxStr;
  303.     }
  304.  
  305.     return $strings;
  306.   }
  307.  
  308.   /**
  309.    * Throws an Exception if the address passed does not comply with RFC 2822.
  310.    * @param string $address
  311.    * @throws Exception If invalid.
  312.    * @access protected
  313.    */
  314.   private function _assertValidAddress($address)
  315.   {
  316.     if (!preg_match('/^' . $this->getGrammar('addr-spec') . '$/D',
  317.       $address))
  318.     {
  319.       throw new Swift_RfcComplianceException(
  320.         'Address in mailbox given [' . $address .
  321.         '] does not comply with RFC 2822, 3.6.2.'
  322.         );
  323.     }
  324.   }
  325.  
  326. }
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#4: 3 Weeks Ago

re: Geeting error:PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' wit


Again, I need to see the code you have written.

Also, please use [code] tags when posting code in the forum.

[code] code goes here [/code]
Newbie
 
Join Date: Oct 2009
Posts: 4
#5: 3 Weeks Ago

re: Geeting error:PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' wit


Here is the whole folder

http://makemycreative.in/source.rar

Rgds
Yash
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#6: 3 Weeks Ago

re: Geeting error:PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' wit


In your index.php file, please set error_reporting(E_ALL);

I suspect you have some errors to do with array keys that are not being shown.
Newbie
 
Join Date: Oct 2009
Posts: 4
#7: 3 Weeks Ago

re: Geeting error:PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' wit


Could please tell me where to set error_reporting(E_ALL);

i am new to php codes, & i just want this sign up form for my website.
so kindly give me an example...

& tell me what kind of array errors.
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#8: 3 Weeks Ago

re: Geeting error:PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' wit


Quote:

Originally Posted by yashmistrey View Post

Could please tell me where to set error_reporting(E_ALL);

i am new to php codes, & i just want this sign up form for my website.
so kindly give me an example...

& tell me what kind of array errors.

At the very top of your index.php file. I'm hoping it will then tell us the errors.
Reply