<?php
/**
 * script modelo/panel_de_busquedas_mail.php
 * 
 **/
 
require_once "class.phpmailer.php";

require_once "____config____.php";
 
$subject    = $referencia." ".$your_name;
if(isset($target_file)){
    $attachment = $target_file;
} else {
    $attachment = "";
    $subject.= " , attachment?";
    echo "nombre del archivo del curriculum no definido";
}
$from_name  = "claudio.vidal@kaver-consulting.com";

function emailWithAttachment($to, $subject, $your_message, $attachment, $from_name, $your_name,  $your_mail) {

    $mail = new PHPMailer();
    $mail->AddReplyTo( $your_mail, $from_name);   // No alterar el orden ! (deja de funcionar el reply to)
    $mail->SetFrom('cv-web@kaver-consulting.com', ' Kaver Curriculums Vitae');
    $mail->AddAddress($to);
    $mail->From         = $from_name;
    $mail->FromName     = $your_name;
    $mail->Subject      = $subject;
    $mail->Body         = $your_message;

    $mail->AddAttachment($attachment);
    
    if(!$mail->Send()) {
      echo "Error mail: " . $mail->ErrorInfo;
    } else {
      //echo "Mail enviado!";
    }
}

emailWithAttachment($to, $subject, $your_message, $attachment, $from_name, $your_name,  $your_mail);

