<?

 
Function SendMail($ParaEmail,$ParaNombre,$SubjectMessage,$BodyHTMLFileMessage,$AdjuntoA,$AdjuntoB,$AdjuntoC)
{


require_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

try {
  /*$mail->Host       = "mail.momatt.com"; // SMTP server
  $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
  $mail->SMTPAuth   = false;                  // enable SMTP authentication
  //$mail->SMTPSecure = "";                 // sets the prefix to the servier
  $mail->Port       = 2525;                   // set the SMTP port for the GMAIL server
  $mail->Username   = "factura";  // GMAIL username
  $mail->Password   = "disxii";            // GMAIL password
  //$mail->AddReplyTo('factura@momatt.com', 'Portal de Clientes');*/
  
  $mail->Host       = "ssl://smtp.gmail.com"; // SMTP server
  //$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
  $mail->SMTPAuth   = true;                  // enable SMTP authentication
  $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
  $mail->Port       = 25;                   // set the SMTP port for the GMAIL server
  $mail->Username   = "soporte@disxii.com";  // GMAIL username
  $mail->Password   = "disxii_50p0r73";            // GMAIL password
  $mail->AddReplyTo('soporte@disxii.com', 'Portal de Clientes');
  
  $emails = explode(",",$ParaEmail);
  $names = explode(",",$ParaNombre);
  for($i=0;$i < count($emails);$i++){
	$mail->AddAddress($emails[$i], $names[$i]);
  }
  
  $mail->SetFrom('soporte@disxii.com', 'Portal de Clientes');
  //$mail->SetFrom('factura@momatt.com', 'Portal de Clientes');
  //$mail->AddReplyTo('soporte@disxii.com', 'Portal de Clientes');
  
  $mail->Subject = $SubjectMessage;
  
  $mail->AltBody = 'Correo electrónico, enviado desde el Portal de Clientes!'; // optional - MsgHTML will create an alternate automatically
  /*if (file_exists($BodyHTMLFileMessage)) {
    $mail->MsgHTML(file_get_contents($BodyHTMLFileMessage));
  } else {
    $mail->MsgHTML("No se especifico el cuerpo del mensaje o no existe el archivo indicado");  
  }*/
  
  $mail->MsgHTML($BodyHTMLFileMessage);
  
  
    if (file_exists($AdjuntoA)) {
        $mail->AddAttachment($AdjuntoA); }
    if (file_exists($AdjuntoB)) {
        $mail->AddAttachment($AdjuntoB); }
    if (file_exists($AdjuntoC)) {
        $mail->AddAttachment($AdjuntoC); }
  
  //$mail->Send();
  if(!$mail->Send()) {
      //echo "<p>: </p>\n" . $mail->ErrorInfo;
			/*echo "<script language='javascript'>
				alert('No se pudo enviar un correo a su cuenta.');
			</script>";*/
		return false;
    } else {
			/*echo "<script language='javascript'>
			alert('En breves instantes recibira un correo.');
			</script>";*/
		return true;
    }
  
  //echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
  echo $e->errorMessage(); //Pretty error messages from PHPMailer
  return false;
} catch (Exception $e) {
  echo $e->getMessage(); //Boring error messages from anything else!
  return false;
}



}

?>