Esempio n. 1
0
 /**
  * Method used to build a properly quoted email address, in the form of
  * "Sender Name" <*****@*****.**>.
  *
  * @access  public
  * @param   string $address The email address value
  * @return  array The address information
  */
 function fixAddressQuoting($address)
 {
     // check if we have a <
     if (strstr($address, '<') && !Mime_Helper::isQuotedPrintable($address)) {
         $address = stripslashes($address);
         // is the address in the format 'name' <address> ?
         if (strstr($address, "'") || strstr($address, ".")) {
             $first_part = substr($address, 0, strpos($address, '<') - 1);
             if ($first_part) {
                 $first_part = '"' . $first_part . '"';
             }
             $second_part = substr($address, strpos($address, '<'));
             $address = $first_part . ' ' . $second_part;
             // if the address was already in the format "'name'" <address>, then this code
             // will end up adding even more double quotes, so let's remove any excess
             return str_replace('""', '"', $address);
         } else {
             return $address;
         }
     } else {
         return $address;
     }
 }
Esempio n. 2
0
 /**
  * Method used to build a properly quoted email address, in the form of
  * "Sender Name" <*****@*****.**>.
  *
  * @param   string $address The email address value
  * @return  array The address information
  */
 public static function fixAddressQuoting($address)
 {
     // split multiple addresses if needed
     $addresses = self::splitAddresses($address);
     $return = array();
     foreach ($addresses as $address) {
         // check if we have a <
         if (strstr($address, '<') && !Mime_Helper::isQuotedPrintable($address)) {
             $address = stripslashes(trim($address));
             // is the address in the format 'name' <address> ?
             if (strstr($address, "'") || strstr($address, '.')) {
                 $bracket_pos = strrpos($address, '<');
                 if ($bracket_pos != 0) {
                     $bracket_pos = $bracket_pos - 1;
                 }
                 $first_part = substr($address, 0, $bracket_pos);
                 if (!empty($first_part)) {
                     $first_part = '"' . str_replace('"', '\\"', preg_replace('/(^")|("$)/', '', $first_part)) . '"';
                 }
                 $second_part = substr($address, strrpos($address, '<'));
                 $address = $first_part . ' ' . $second_part;
                 // if the address was already in the format "'name'" <address>, then this code
                 // will end up adding even more double quotes, so let's remove any excess
                 $return[] = str_replace('""', '"', $address);
             } else {
                 $return[] = $address;
             }
         } else {
             $return[] = $address;
         }
     }
     return implode(',', $return);
 }