Contacto: '.$nombre.'
'.
'Email: '.$email.'
'.
'Mensaje: '.$mensaje1.'
';
if(isset($_FILES['archivo']) and $_FILES['archivo']['size']>0){
//Get uploaded file data
$file_tmp_name = $_FILES['archivo']['tmp_name'];
$file_name = $_FILES['archivo']['name'];
$file_size = $_FILES['archivo']['size'];
$file_type = $_FILES['archivo']['type'];
$file_error = $_FILES['archivo']['error'];
if($file_error > 0)
{
die('Upload error or No files uploaded');
}
//read from the uploaded file & base64_encode content for the mail
$handle = fopen($file_tmp_name, "r");
$content = fread($handle, $file_size);
fclose($handle);
$encoded_content = chunk_split(base64_encode($content));
}
$boundary = md5("sanwebe");
//header
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From:webmaster@cocinasdalloway.com\r\n";
//$headers .= "Reply-To: ".$reply_to_email."" . "\r\n";
$headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n";
//plain text
$body = "--$boundary\r\n";
$body .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$body .= "Content-Transfer-Encoding: base64\r\n\r\n";
$body .= chunk_split(base64_encode($mensaje));
if(isset($_FILES['archivo']) and $_FILES['archivo']['size']>0){
//attachment
$body .= "--$boundary\r\n";
$body .="Content-Type: $file_type; name=".$file_name."\r\n";
$body .="Content-Disposition: attachment; filename=".$file_name."\r\n";
$body .="Content-Transfer-Encoding: base64\r\n";
$body .="X-Attachment-Id: ".rand(1000,99999)."\r\n\r\n";
$body .= $encoded_content;
}
if(mail($para, $titulo, $body, $headers))
{
header('Location: http://www.cocinasdalloway.com/');
exit;
}else{
echo $errorMessage = error_get_last()['message'];
}
}else{
header("refresh:5;url=https://www.cocinasdalloway.com/contacto.html");
echo 'You are spammer !';
}
?>