il codice è questo...
con la variabile $body_html che contiene il messaggio formattato come una comune pagina html da <html> a </html> con <style></style> etc...
su hotmail il problema non è di stile... non si vede proprio!
mentre su aruba si vede male ma si vede...
Codice PHP:
<?
function send_mail($email,$subject,$body_html,$body_txt,$mittente,$file_path_and_name="",$new_file_name=""){
$boundary_1 ="mixed_part_".md5(time());
$boundary_2 ="alternative_part_".md5(time());
$headers = "From: $mittente\n";
$headers.= "X-Mailer: basula PHP code\n";
$headers.= "MIME-version: 1.0\n";
if ($file_path_and_name!=""){
$headers.= "Content-Type: multipart/mixed; boundary=\"$boundary_1\"\n";
$headers.= "\n\r--$boundary_1\n";
}
$headers.= "Content-Type: multipart/alternative; boundary=\"$boundary_2\"\n";
//mail alternativa solo testo
$body = "\n\r--$boundary_2\n";
$body.= "Content-Type: text/plain; charset=ISO-8859-15; format=flowed\n";
$body.= "Content-Transfer-Encoding: 7bit\n\n";
$body.= "$body_txt";
//mail html
$body.= "\n\r--$boundary_2\n";
$body.= "Content-Type: text/html; charset=ISO-8859-15\n";
$body.= "Content-Transfer-Encoding: 7bit\n\n";
$body.= "$body_html";
//fine part alternative
$body .= "\n\r--$boundary_2--\n";
//allegato se presente
if ($file_path_and_name != "") {
$open_file = fopen($file_path_and_name, "r");
$data = fread($open_file, filesize($file_path_and_name));
$encoded_attach = base64_encode($data);
fclose($open_file);
$file_name = array_pop(explode('/',$file_path_and_name));
if ($new_file_name == "") $new_file_name = $file_name;
$file_type = mime_content_type($file_path_and_name);
$body.= "\n\r--$boundary_1\n";
$body.= "Content-type: $file_type; name=\"$file_name\"\n";
$body.= "Content-Transfer-Encoding: base64\n";
$body.= "Content-Disposition: attachment; filename=\"$new_file_name\"\n\n";
$body.= "$encoded_attach\n";
$body.= "\n\r--$boundary_1--\n";
}
if(@mail($email,$subject,$body,$headers)) return true; else return false;
}
?>