Exemplo n.º 1
0
 /**
  * Send email
  *
  * Uses the new XoopsMultiMailer
  *
  * @param string $
  * @param string $
  * @param string $
  * @return boolean FALSE on error.
  */
 function sendMail($email, $subject, $body, $headers)
 {
     $subject = $this->encodeSubject($subject);
     $this->encodeBody($body);
     $this->multimailer->ClearAllRecipients();
     $this->multimailer->AddAddress($email);
     $this->multimailer->Subject = $subject;
     $this->multimailer->Body = $body;
     $this->multimailer->CharSet = $this->charSet;
     $this->multimailer->Encoding = $this->encoding;
     if (!empty($this->fromName)) {
         $this->multimailer->FromName = $this->encodeFromName($this->fromName);
     }
     if (!empty($this->fromEmail)) {
         $this->multimailer->Sender = $this->multimailer->From = $this->fromEmail;
     }
     $this->multimailer->ClearCustomHeaders();
     foreach ($this->headers as $header) {
         $this->multimailer->AddCustomHeader($header);
     }
     if (!$this->multimailer->Send()) {
         $this->errors[] = $this->multimailer->ErrorInfo;
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Send email
  *
  * Uses the new XoopsMultiMailer
  *
  * @param	string
  * @param	string
  * @param	string
  * @return	boolean	FALSE on error.
  */
 function sendMail($email, $subject, $body, $headers)
 {
     $subject = $this->encodeSubject($subject);
     $this->encodeBody($body);
     $this->multimailer->ClearAllRecipients();
     $this->multimailer->AddAddress($email);
     $this->multimailer->Subject = $subject;
     $this->multimailer->Body = $body;
     $this->multimailer->CharSet = $this->charSet;
     $this->multimailer->Encoding = $this->encoding;
     $this->multimailer->FromName = $this->encodeFromName($GLOBALS['xoopsConfig']['sitename']);
     if (!$this->multimailer->Send()) {
         $this->errors[] = $this->multimailer->ErrorInfo;
         return FALSE;
     }
     return TRUE;
 }
Exemplo n.º 3
0
 function EncodeHeader($str, $position = 'text', $force = false)
 {
     if (!preg_match('/^4\\.4\\.[01]([^0-9]+|$)/', PHP_VERSION)) {
         if (function_exists('mb_convert_encoding')) {
             //Use mb_string extension if exists.
             if ($this->needs_encode || $force) {
                 $encoded = mb_convert_encoding($str, _CHARSET, mb_detect_encoding($str));
                 $encoded = mb_encode_mimeheader($encoded, "ISO-2022-JP", "B", "\n");
             } else {
                 $encoded = $str;
             }
         } else {
             $encoded = parent::EncodeHeader($str, $position);
         }
         return $encoded;
     } else {
         //Following Logic are made for recovering PHP4.4.0 and 4.4.1 mb_encode_mimeheader() bug.
         //TODO: If mb_encode_mimeheader() bug is fixed. Replace this to simple logic.
         $encode_charset = strtoupper($this->CharSet);
         if (function_exists('mb_convert_encoding')) {
             //Using mb_string extension if exists.
             if ($this->needs_encode || $force) {
                 $str_encoding = mb_detect_encoding($str, 'ASCII,' . $encode_charset);
                 if ($str_encoding == 'ASCII') {
                     // Return original if string from only ASCII chars.
                     return $str;
                 } else {
                     if ($str_encoding != $encode_charset) {
                         // Maybe this case may not occur.
                         $str = mb_convert_encoding($str, $encode_charset, $str_encoding);
                     }
                 }
                 $cut_start = 0;
                 $encoded = '';
                 $cut_length = floor((76 - strlen('Subject: =?' . $encode_charset . '?B?' . '?=')) / 4) * 3;
                 while ($cut_start < strlen($str)) {
                     $partstr = mb_strcut($str, $cut_start, $cut_length, $encode_charset);
                     $partstr_length = strlen($partstr);
                     if (!$partstr_length) {
                         break;
                     }
                     if ($encode_charset == 'ISO-2022-JP') {
                         //Should Adjust next cutting place for SO & SI char insertion.
                         if (substr($partstr, 0, 3) === chr(27) . '$B' && substr($str, $cut_start, 3) !== chr(27) . '$B') {
                             $partstr_length -= 3;
                         }
                         if (substr($partstr, -3) === chr(27) . '(B' && substr($str, $cut_start + $partstr_length - 3, 3) !== chr(27) . '(B') {
                             $partstr_length -= 3;
                         }
                     }
                     if ($cut_start) {
                         $encoded .= "\r\n\t";
                     }
                     $encoded .= '=?' . $encode_charset . '?B?' . base64_encode($partstr) . '?=';
                     $cut_start += $partstr_length;
                 }
             } else {
                 $encoded = $str;
             }
         } else {
             $encoded = parent::EncodeHeader($str, $position);
         }
         return $encoded;
     }
 }
Exemplo n.º 4
0
 function encodeHeader($str, $position = 'text', $force = false)
 {
     if (version_compare(PHP_VERSION, '4.4.1') > 0) {
         if (function_exists('mb_convert_encoding')) {
             //Use mb_string extension if exists.
             if ($this->needs_encode || $force) {
                 $enc = mb_internal_encoding();
                 mb_internal_encoding('ISO-2022-JP');
                 $eol = $this->Mailer == 'mail' ? defined('XCUBE_MAILERLOCAL_MAIL_LE') ? XCUBE_MAILERLOCAL_MAIL_LE : "\r\n" : "\n";
                 // XXX: this for bugs in PHP mail() subject with linefeed handling
                 $encoded = mb_encode_mimeheader($str, 'ISO-2022-JP', 'B', $eol, 9);
                 // offset strlen("Subject: ") as 9
                 mb_internal_encoding($enc);
             } else {
                 $encoded = $str;
             }
         } else {
             $encoded = parent::EncodeHeader($str, $position);
         }
         return $encoded;
     } else {
         //Following Logic are made for recovering PHP4.4.0 and 4.4.1 mb_encode_mimeheader() bug.
         //TODO: If mb_encode_mimeheader() bug is fixed. Replace this to simple logic.
         $encode_charset = strtoupper($this->CharSet);
         if (function_exists('mb_convert_encoding')) {
             //Using mb_string extension if exists.
             if ($this->needs_encode || $force) {
                 $str_encoding = mb_detect_encoding($str, 'ASCII,' . $encode_charset);
                 if ($str_encoding == 'ASCII') {
                     // Return original if string from only ASCII chars.
                     return $str;
                 } else {
                     if ($str_encoding != $encode_charset) {
                         // Maybe this case may not occur.
                         $str = mb_convert_encoding($str, $encode_charset, $str_encoding);
                     }
                 }
                 $cut_start = 0;
                 $encoded = '';
                 $cut_length = floor((76 - strlen('Subject: =?' . $encode_charset . '?B?' . '?=')) / 4) * 3;
                 while ($cut_start < strlen($str)) {
                     $partstr = mb_strcut($str, $cut_start, $cut_length, $encode_charset);
                     $partstr_length = strlen($partstr);
                     if (!$partstr_length) {
                         break;
                     }
                     if ($encode_charset == 'ISO-2022-JP') {
                         //Should Adjust next cutting place for SO & SI char insertion.
                         if (substr($partstr, 0, 3) === chr(27) . '$B' && substr($str, $cut_start, 3) !== chr(27) . '$B') {
                             $partstr_length -= 3;
                         }
                         if (substr($partstr, -3) === chr(27) . '(B' && substr($str, $cut_start + $partstr_length - 3, 3) !== chr(27) . '(B') {
                             $partstr_length -= 3;
                         }
                     }
                     if ($cut_start) {
                         $encoded .= "\r\n\t";
                     }
                     $encoded .= '=?' . $encode_charset . '?B?' . base64_encode($partstr) . '?=';
                     $cut_start += $partstr_length;
                 }
             } else {
                 $encoded = $str;
             }
         } else {
             $encoded = parent::EncodeHeader($str, $position);
         }
         return $encoded;
     }
 }
Exemplo n.º 5
0
 function XoopsMultiMailerLocal()
 {
     parent::XoopsMultiMailer();
 }
 function encode_header($str, $position = 'text', $force = false)
 {
     $encode_charset = 'ISO-2022-JP';
     //ToDo: Initialize with $this->Charset, but it won't work well now.
     if (function_exists('mb_convert_encoding')) {
         //Using mb_string extension if exists.
         if ($this->needs_encode || $force) {
             $str_encoding = mb_detect_encoding($str, 'ASCII,' . $encode_charset);
             if ($str_encoding == 'ASCII') {
                 // Return original if string from only ASCII chars.
                 return $str;
             } else {
                 if ($str_encoding != $encode_charset) {
                     // Maybe this case may not occur.
                     $str = mb_convert_encoding($str, $encode_charset, $str_encoding);
                 }
             }
             //Following Logic are made for recovering PHP4.4.x mb_encode_mimeheader() bug.
             //TODO: If mb_encode_mimeheader() bug is fixed. Replace this to simple logic.
             $cut_start = 0;
             $encoded = '';
             $cut_length = floor((76 - strlen('Subject: =?' . $encode_charset . '?B?' . '?=')) / 4) * 3;
             while ($cut_start < strlen($str)) {
                 $partstr = mb_strcut($str, $cut_start, $cut_length, $encode_charset);
                 $partstr_length = strlen($partstr);
                 if (!$partstr_length) {
                     break;
                 }
                 if ($encode_charset == 'ISO-2022-JP') {
                     //Should Adjust next cutting place for SO & SI char insertion.
                     if (substr($partstr, 0, 3) === chr(27) . '$B' && substr($str, $cut_start, 3) !== chr(27) . '$B') {
                         $partstr_length -= 3;
                     }
                     if (substr($partstr, -3) === chr(27) . '(B' && substr($str, $cut_start + $partstr_length - 3, 3) !== chr(27) . '(B') {
                         $partstr_length -= 3;
                     }
                 }
                 if ($cut_start) {
                     $encoded .= "\r\n\t";
                 }
                 $encoded .= '=?' . $encode_charset . '?B?' . base64_encode($partstr) . '?=';
                 $cut_start += $partstr_length;
             }
         } else {
             $encoded = $str;
         }
     } else {
         $encoded = parent::encode_header($str, $position);
     }
     return $encoded;
 }