当前位置: 首页>>代码示例>>PHP>>正文


PHP htmlMimeMail::setHeadCharset方法代码示例

本文整理汇总了PHP中htmlMimeMail::setHeadCharset方法的典型用法代码示例。如果您正苦于以下问题:PHP htmlMimeMail::setHeadCharset方法的具体用法?PHP htmlMimeMail::setHeadCharset怎么用?PHP htmlMimeMail::setHeadCharset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在htmlMimeMail的用法示例。


在下文中一共展示了htmlMimeMail::setHeadCharset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send

 public static function send($from, $to, $subject, $body, array $attachments = null, array $headers = null)
 {
     if (empty($to)) {
         Logger::trace("mail not sent: no recipients: {$subject}");
         return;
     }
     $config = Context::last()->config;
     if (empty($from)) {
         if (!($from = $config->get('modules/mail/from'))) {
             $from = "Molinos.CMS <no-reply@" . MCMS_HOST_NAME . ">";
         }
     }
     if (strstr($body, '<html>') === false) {
         $body = '<html><head><title>' . html::plain($subject) . '</title></head><body>' . $body . '</body></html>';
     }
     if (!is_array($to)) {
         $to = preg_split('/, */', $to, -1, PREG_SPLIT_NO_EMPTY);
     }
     Logger::log(sprintf('to=%s, subject=%s', join(',', $to), $subject), 'mail');
     $mail = new htmlMimeMail();
     if ('smtp' == ($transport = ($server = $config->get('modules/mail/server')) ? 'smtp' : 'mail')) {
         $mail->setSMTPParams($server);
     }
     $mail->setFrom($from);
     $mail->setSubject($subject);
     $mail->setHtml(self::fixhtml($body));
     $mail->setTextCharset('UTF-8');
     $mail->setTextEncoding('base64');
     $mail->setHTMLCharset('UTF-8');
     $mail->setHTMLEncoding('UTF-8');
     $mail->setHeadCharset('UTF-8');
     foreach ((array) $attachments as $file) {
         $mail->addAttachment($file['data'], $file['name'], $file['type']);
     }
     foreach ((array) $headers as $k => $v) {
         if (!empty($v)) {
             $mail->setHeader($k, $v);
         }
     }
     return $mail->send($to, $transport);
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:41,代码来源:class.bebopmimemail.php

示例2: SendMail_HTML

function SendMail_HTML($from, $to, $subj, $body, $attach = "")
{
    // sending email as html
    //global $SERVER_SOFTWARE;
    $mail = new htmlMimeMail();
    $mail->setFrom($from);
    $mail->setSubject($subj);
    $mail->setHTML($body);
    $mail->setHTMLCharset('windows-1251');
    $mail->setHeadCharset('windows-1251');
    if (is_array($attach)) {
        $total = count($attach);
        for ($i = 0; $i < $total; $i++) {
            if (file_exists($attach[$i])) {
                $attach_data = $mail->getFile($attach[$i]);
                $mail->addAttachment($attach_data, basename($attach[$i]), '');
            }
        }
    } elseif (file_exists($attach) && $attach != "") {
        $attach_data = $mail->getFile($attach);
        $mail->addAttachment($attach_data, basename($attach), '');
    }
    $result = $mail->send(array($to));
    return $result;
}
开发者ID:NioFBI,项目名称:majordomo,代码行数:25,代码来源:general.class.php

示例3: send_mail

/**
 * Send e-mails
 *
 * @param String $to      Recipient mail address
 * @param String $subject Subject
 * @param String $message Mail content
 * @param String $from    Sender mail address
 * @param Array  $headers Additional mail headers
 *
 * @return Bool Returs true if mail has been sent
 */
function send_mail($to, $subject, $message, $from, $headers = NULL)
{
    global $configuration;
    $mail = new htmlMimeMail();
    if ($configuration['mail_type'] == 'smtp') {
        $type = 'smtp';
        $smtp = $configuration['smtp'];
        $mail->setSMTPParams($smtp['host'], $smtp['port'], $smtp['helo'], $smtp['auth'], $smtp['user'], $smtp['pass']);
    } else {
        $type = 'mail';
    }
    // Set additional mail headers
    $html = false;
    if (is_array($headers)) {
        foreach ($headers as $name => $value) {
            $mail->setHeader($name, $value);
            if (strtolower($name) == 'content-type' and preg_match('#text/html#i', $value)) {
                $mail->setHtmlCharset($configuration['character_set']);
                $mail->setHtml($message);
                $html = true;
            }
            // Set return path
            if (strtolower($name) == 'return-path') {
                $mail->setReturnPath($value);
            }
        }
    }
    $mail->setHeadCharset($configuration['character_set']);
    $mail->setFrom($from);
    $mail->setSubject($subject);
    if ($html != true) {
        $configuration['character_set'];
        $mail->setTextCharset($configuration['character_set']);
        $mail->setText($message);
    }
    $result = $mail->send(array($to), $type);
    if ($result) {
        return true;
    }
}
开发者ID:Nenet,项目名称:Urban,代码行数:51,代码来源:functions.inc.php

示例4: array

 function users_sendspam()
 {
     if (!$this->haveAccessTo('sendspam-users')) {
         return $this->showAccessDenied();
     }
     $aData = array();
     $aSelectedUsers = func::POSTGET('user_id', false);
     if (is_array($aSelectedUsers)) {
         $aSelectedUsers = array_unique($aSelectedUsers);
     }
     $sFrom = self::SENDSPAM_FROM;
     if (func::isPostMethod() || func::POSTGET('submit') == 'send') {
         $sSubject = func::POSTGET('subject', true);
         $sBody = func::POSTGET('body', true);
         if (!$sSubject) {
             $this->errors->set('no_subject');
         }
         if (!$sBody) {
             $this->errors->set('no_body');
         }
         if (!is_array($aSelectedUsers) || count($aSelectedUsers) == 0) {
             $this->errors->set('no_receivers');
         }
         if ($this->errors->no()) {
             //get users
             $sQueryAdd = '';
             if (isset($aSelectedUsers)) {
                 $sQueryAdd = ' WHERE id IN (' . implode(',', $aSelectedUsers) . ') ';
             }
             if (self::SENDSPAM_SUBSCRIBED_USERS) {
                 $sQueryAdd = ' WHERE subscribed=1 ';
             }
             $aUsers = $this->db->select('SELECT * FROM ' . TABLE_USERS . ' ' . $sQueryAdd . ' ORDER BY login');
             include PATH_CORE . 'mail/htmlMimeMail.php';
             @set_time_limit(0);
             $nCountSuccessfull = 0;
             $nCountUnsuccessfull = 0;
             $aUsersSuccessfull = array();
             $oMail = new htmlMimeMail();
             $oMail->setHeadCharset('UTF-8');
             $oMail->setTextCharset('UTF-8');
             $oMail->setSubject($sSubject);
             $oMail->setFrom($sFrom);
             $oMail->setText($sBody);
             for ($i = 0; $i < count($aUsers); $i++) {
                 if (@$oMail->send(array($aUsers[$i]['email']))) {
                     $nCountSuccessfull++;
                     $aUsersSuccessfull[] = $aUsers[$i]['id'];
                 } else {
                     $nCountUnsuccessfull++;
                 }
             }
             if ($nCountUnsuccessfull == 0) {
                 $this->adminRedirect(Errors::SUCCESSFULL, 'users_sendspam');
             } else {
                 $this->errors->set('result_of_sendmail', false, 'успешно - ' . $nCountSuccessfull . ' / с ошибками - ' . $nCountUnsuccessfull);
                 //leave only unsuccessfull users :)
                 $aSelectedUsers = array_diff($aSelectedUsers, $aUsersSuccessfull);
             }
         }
         $aData = $_REQUEST;
     }
     $aUsers = $this->db->select('SELECT id, email, login FROM ' . TABLE_USERS . ' ' . (self::SENDSPAM_SUBSCRIBED_USERS ? ' WHERE subscribed=1 ' : '') . ' ORDER BY login');
     $htmlExistsOptions = '';
     $htmlReceiversOptions = '';
     for ($i = 0; $i < count($aUsers); $i++) {
         if (!$aUsers[$i]['email']) {
             continue;
         }
         $htmlItem = '<option value="' . $aUsers[$i]['id'] . '">' . $aUsers[$i]['login'] . ' &lt;' . $aUsers[$i]['email'] . '&gt; </option>';
         if (is_array($aSelectedUsers) && in_array($aUsers[$i]['id'], $aSelectedUsers)) {
             $htmlReceiversOptions .= $htmlItem;
         } else {
             $htmlExistsOptions .= $htmlItem;
         }
     }
     $aData['from'] = $sFrom;
     $this->tplAssign('aData', $aData);
     $this->tplAssign("exists_values", $htmlExistsOptions);
     $this->tplAssign("sendtousers_options", $htmlReceiversOptions);
     return $this->tplFetch('admin.users.sendspam.tpl');
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:82,代码来源:sendmail.adm.class.php

示例5: die

        . "LIMIT " . $nCuantos ;
  $nResultado = mysql_query ($cSql) or die("Error en la consulta: " . $cSql . " Tipo de error: " . mysql_error());

  $nFilasTot = mysql_num_rows($nResultado) ;
  $nFilasAct = 0 ;

  while ($aRegistro = mysql_fetch_array($nResultado)) {
    $nFilasAct++ ;

    $oMail = new htmlMimeMail();
    $oMail->setHeader('X-Mailer', 'HTML Mime mail');
    $oMail->setHeader('MIME-Version', '1.0');
//  $oMail->setHeader('Content-type', 'text/html;charset=ISO-8859-9');
  $oMail->setTextCharset("utf-8");
  $oMail->setHTMLCharset("utf-8");
  $oMail->setHeadCharset("utf-8");

    $cTexto = $oMail->getFile("./Newsletter/Newsletter.txt");
    $cTexto = str_replace("##Contenido##", $cContTexto, $cTexto);
    $cTexto = str_replace("##Nombre##", ucwords(strtolower($aRegistro['UsrFirstName1'])), $cTexto);
    $cTexto = str_replace("##EMail##", $aRegistro["UsrEMail1"], $cTexto);
    $cTexto = str_replace("##Clave##", $aRegistro["UsrPassword"], $cTexto);
    $cTexto = str_replace("##ClaveBaja##", md5("#".$aRegistro["UsrCode"]."#".$aRegistro["UsrEMail1"]."#"), $cTexto);

    $cHTML  = $oMail->getFile("./Newsletter/Newsletter.html");
    $cHTML  = str_replace("##Contenido##", $cContHTML, $cHTML);
    $cHTML  = str_replace("##Nombre##", ucwords(strtolower($aRegistro['UsrFirstName1'])), $cHTML);
    $cHTML  = str_replace("##EMail##", $aRegistro["UsrEMail1"], $cHTML);
    $cHTML  = str_replace("##Clave##", $aRegistro["UsrPassword"], $cHTML);		
    $cHTML  = str_replace("##ClaveBaja##", md5("#".$aRegistro["UsrCode"]."#".$aRegistro["UsrEMail1"]."#"), $cHTML);
开发者ID:rusoftware,项目名称:GrupoNorte,代码行数:30,代码来源:Enviar.php

示例6: stripslashes


//.........这里部分代码省略.........
                     if (trim(str_replace('X-Form-Mail-Attachment:', '', $header_info[$k])) == 'no') {
                         $send_attachments = false;
                     }
                     unset($header_info[$k]);
                     continue;
                 }
                 if (preg_match("/^" . $mail_header . "/i", $header_info[$k], $match)) {
                     $additional_headers[] = $header_info[$k];
                     $attachment_headers[str_replace(':', '', $match[0])] = trim(preg_replace("/" . $match[0] . "/i", '', $header_info[$k]));
                     unset($header_info[$k]);
                     continue;
                 }
             }
             if (isset($header_info) and is_array($header_info)) {
                 $new_mail_content = trim(implode($header_info, "\n"));
                 $new_mail_content = str_replace("\r", '', $new_mail_content);
             } else {
                 $new_mail_content = '';
             }
             //                if (isset($additional_headers) and is_array($additional_headers)) {
             //                    $additional_headers = implode($additional_headers, "\n");
             //                } else {
             //                    $additional_headers = '';
             //                }
             /**
              * Wrap mail content (and only mail content - not
              * headers).
              */
             $new_mail_content = $this->wrap_content($new_mail_content, $text_wrap);
             /**
              * Send mail using simple mail function
              */
             if (!$send_attachments and $debug_mode != 'on' and $mail_recipient != '') {
                 //  @mail ($mail_recipient, $mail_subject, $new_mail_content, $additional_headers);
                 send_mail($mail_recipient, $mail_subject, $new_mail_content, $mail_from, $attachment_headers);
             }
             /**
              * Send mail using mail class
              */
             if ($send_attachments and $debug_mode != 'on' and $mail_recipient != '') {
                 $att = new htmlMimeMail();
                 // Switch to smtp mode
                 if ($configuration['mail_type'] == 'smtp') {
                     $type = 'smtp';
                     $smtp = $configuration['smtp'];
                     $att->setSMTPParams($smtp['host'], $smtp['port'], $smtp['helo'], $smtp['auth'], $smtp['user'], $smtp['pass']);
                 } else {
                     $type = 'mail';
                 }
                 // Register file attachments in mime class
                 foreach ($this->attachments as $file_name) {
                     $att->addAttachment($att->getFile($file_name['new']), $file_name['old']);
                 }
                 //Manage mail var attachments
                 if (isset($configuration['attach_mail_vars']) and is_array($configuration['attach_mail_vars']) and sizeof($configuration['attach_mail_vars']) > 0) {
                     foreach ($configuration['attach_mail_vars'] as $attach_type) {
                         if ($attach_type == 'vcard') {
                             $attach_config = array('mailvars' => $post_data, 'type' => G10E_ATTACH_TYPE_VCARD, 'control' => $this->control_fields);
                             if ($res = attach_mail_variables::get_content($attach_config)) {
                                 $att->addAttachment($res, 'vcard.vcf');
                             }
                         }
                         if ($attach_type == 'csv') {
                             $attach_config = array('mailvars' => $post_data, 'type' => G10E_ATTACH_TYPE_CSV, 'control' => $this->control_fields, 'csv_head' => true);
                             if ($res = attach_mail_variables::get_content($attach_config)) {
                                 $att->addAttachment($res, 'csv.csv');
                             }
                         }
                     }
                 }
                 // Register headers in mime class
                 $html = false;
                 if (isset($attachment_headers) and is_array($attachment_headers)) {
                     foreach ($attachment_headers as $key => $val) {
                         $att->setHeader($key, $val);
                         if ($key == 'Content-Type' and preg_match('#text/html#i', $val)) {
                             $att->setHtmlCharset($configuration['character_set']);
                             $att->setHtml($new_mail_content);
                             $html = true;
                         }
                     }
                 }
                 $att->setHeadCharset($configuration['character_set']);
                 $att->setSubject($mail_subject);
                 if ($html != true) {
                     $att->setTextCharset($configuration['character_set']);
                     $att->setText($new_mail_content);
                 }
                 $att->send(array($mail_recipient), $type);
             }
             debug_mode($mail_recipient, 'Mail Recipient mail()');
             debug_mode($mail_subject, 'Mail Subject mail()');
             debug_mode($new_mail_content, 'Mail Content mail()');
             debug_mode($additional_headers, 'Mail Additional Headers mail()');
         }
     }
     // -re- for
     $this->mail_content = $mail_content[0];
     return array('status' => 'ok', 'mail_content' => $this->mail_content);
 }
开发者ID:Nenet,项目名称:Urban,代码行数:101,代码来源:formmail.class.inc.php


注:本文中的htmlMimeMail::setHeadCharset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。