Spedisci mail da php

{
// email stuff (change data below)
$to = $to_temp;
$from = “tuamail@tuodominio.es”;
$subject = $subject_temp;
$message = $message_temp;
// a random hash will be necessary to send mixed content
$separator = md5(time());

// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;

// attachment name
$filename = $file_name_temp;
$attachment = chunk_split(base64_encode($attach__temp));
// main header (multipart mandatory)
$headers = “From: “.$from.$eol;
$headers .= “MIME-Version: 1.0”.$eol;
$headers .= “Content-Type: multipart/mixed; boundary=\””.$separator.”\””.$eol.$eol;
$headers .= “Content-Transfer-Encoding: 7bit”.$eol;
$headers .= “This is a MIME encoded message.”.$eol.$eol;
// message
$headers .= “–“.$separator.$eol;
$headers .= “Content-Type: text/html; charset=\”iso-8859-1\””.$eol;
$headers .= “Content-Transfer-Encoding: 8bit”.$eol.$eol;
$headers .= $message.$eol.$eol;
// attachment
$headers .= “–“.$separator.$eol;
$headers .= “Content-Type: application/octet-stream; name=\””.$filename.”\””.$eol;
$headers .= “Content-Transfer-Encoding: base64”.$eol;
$headers .= “Content-Disposition: attachment”.$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= “–“.$separator.”–“;
mail($to, $subject, “”, $headers);
// send message

}

?>;