<?php
$boundary='didondinaditondelosdudosdodudundodudindon';
$email_to = "emaildestino";
$bounce_email = "emaildestino";
$reply_to = $_POST['email'];
$from = $_POST['email'];
$email_from = $from; // Email del remitente
$email_subject = $_POST["dominio"]; // Asunto del mail
$email_txt = $_POST['comentarios']; // Texto en el cuerpo del mensaje
$headers = "From: $email_from \n";
$headers .= "Reply-To: $reply_to \n";
$headers .= "X-Mailer:PHP/".phpversion()."\n";
$headers .= "Mime-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n\n";
// Mostrando el texto en el cuerpo del mensaje
$email_message = "--". $boundary ."\n"; //Apertura de frontera
$email_message .= "Content-Type: text/html; charset=utf-8 \r\n\n";
$email_message .= "$email_txt\n\n";
// Leyendo el archivo para adjuntar
$newfile = $_POST['adjunto'];
$fileatt = "files/" . $newfile;
$fileatt_type = "application/octet-stream";
$fileatt_name = $_POST['adjunto'];
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$data = chunk_split(base64_encode($data));
// Adjuntando archivo
if ($fileatt_name == "") {
$email_message .= "";
} else {
$email_message = $email_message . "--" .$boundary. "\n";
$email_message .= "Content-Type: {$fileatt_type}; name=\"{$fileatt_name}\"\n";
$email_message .= "Content-Disposition: attachment; filename=\"{$fileatt_name}\"\n";
$email_message .= "Content-Transfer-Encoding: base64\n\n";
$email_message .= $data . "\n\n";
}
$email_message = $email_message . "--" . $boundary ."--"; //Cierre de frontera
//Enviando el mail
$ok = @mail($email_to, $email_subject, $email_message, $headers);
?>
