<?php
/* Send email (text/html) using MIME
 This is the central mail function. The SMTP Server should be configured
 correct in php.ini
 depend class class.email.php
 Parameters:
 $to_name           The name of the recipient, e.g. "Jan Wildeboer"
 $to_email_address  The eMail address of the recipient,
                    e.g. jan.wildeboer@gmx.de
 $email_subject     The subject of the eMail
 $email_text        The text of the eMail, may contain HTML entities
 $from_email_name   The name of the sender, e.g. Shop Administration
 $from_email_adress The eMail address of the sender,
                    e.g. info@mytepshop.com */
function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {
    error_reporting(E_ALL);
    if (!test_const('SEND_EMAILS')) return false;

include_once('lib_partage/class.phpmailer-lite.php');

try {
  $mail = new PHPMailerLite(true); //New instance, with exceptions enabled
  $body             = preg_replace('/\\\\/','', htmlentities($email_text)); //Strip backslashes
  $mail->AddReplyTo($from_email_address,$from_email_name);
  $mail->SetFrom($from_email_address, $from_email_name);
  $mail->AddAddress($to_email_address);
  $mail->Subject  = $email_subject;
  $mail->AltBody    = strip_tags($email_text);//"To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  $mail->WordWrap   = 80; // set word wrap
  $mail->MsgHTML($body);
  $mail->IsHTML(test_const('EMAIL_USE_HTML')); // send as HTML

  $mail->Send();
//   echo 'Message has been sent.';


} catch (phpmailerException $e) {
  echo $e->errorMessage();
  return false;
}
  return true;

}
?>