Пример #1
0
 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);
 }
Пример #2
0
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;
}
Пример #3
0
        . "WHERE " . $cFiltro . " "
        . "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);