function send_html_mail($recipients, $sender, $subject, $html, $text = null, $charset = 'windows-1251')
{
  $mail =& create_mailer();
  $mail->IsHTML(true);
  $mail->CharSet = $charset;

  $mail->Body = $html;

  if(!is_null($text))
    $mail->AltBody = $text;

  $recipients = process_mail_recipients($recipients);

  foreach($recipients as $recipient)
    $mail->AddAddress($recipient['address'], $recipient['name']);

  if(!$sender = process_mail_addressee($sender))
    return false;

  $mail->From = $sender['address'];
  $mail->FromName = $sender['name'];
  $mail->Subject = $subject;

  return $mail->Send();
}
function send_html_mail($recipients, $sender, $subject, $html, $text = null, $charset = 'windows-1251')
{
    $mail =& create_mailer();
    $mail->IsHTML(true);
    $mail->CharSet = $charset;
    $mail->Body = $html;
    if (!is_null($text)) {
        $mail->AltBody = $text;
    }
    $recipients = process_mail_recipients($recipients);
    foreach ($recipients as $recipient) {
        $mail->AddAddress($recipient['address'], $recipient['name']);
    }
    if (!($sender = process_mail_addressee($sender))) {
        return false;
    }
    $mail->From = $sender['address'];
    $mail->FromName = $sender['name'];
    $mail->Subject = $subject;
    if (!($res = $mail->Send())) {
        debug::write_error('mail send error', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, $recipient);
    }
    return $res;
}