aca te mando una funcion espero te sirva
$from = "Nombre";
$email = "
[email protected]";
$to_name = "Nombre detino";
$to_email = "
[email protected]";
$subject = "Asunto";
$TEXT="texton.";
$HTML="Texto con html";
$ATTM=array("file.xls");
SendMail($email,$from, //sender
$to_name,$to_email, //recipient
$subject, //subject
$TEXT,$HTML,$ATTM); //body and attachment(s)
function SendMail($From,$FromName,$To,$ToName,$Subject,$Text,$Html,$AttmFiles){
$OB="----=_OuterBoundary_000";
$IB="----=_InnerBoundery_001";
$Html=$Html?$Html:preg_replace("/n/","{br}",$Text)
or die("neither text nor html part present.");
$Text=$Text?$Text:"Sorry, but you need an html mailer to read this mail.";
$From or die("sender address missing");
$To or die("recipient address missing");
$headers ="MIME-Version: 1.0rn";
$headers.="From: ".$FromName." <".$From.">n";
$headers.="To: ".$ToName." <".$To.">n";
$headers.="Reply-To: ".$FromName." <".$From.">n";
$headers.="X-Priority: 1n";
$headers.="X-MSMail-Priority: Highn";
$headers.="X-Mailer: My PHP Mailern";
$headers.="Content-Type: multipart/mixed;ntboundary="".$OB.""n";
//Messages start with text/html alternatives in OB
$Msg ="This is a multi-part message in MIME format.n";
$Msg.="n--".$OB."n";
$Msg.="Content-Type: multipart/alternative;ntboundary="".$IB.""nn";
//plaintext section
$Msg.="n--".$IB."n";
$Msg.="Content-Type: text/plain;ntcharset="iso-8859-1"n";
$Msg.="Content-Transfer-Encoding: quoted-printablenn";
// plaintext goes here
$Msg.=$Text."nn";
// html section
$Msg.="n--".$IB."n";
$Msg.="Content-Type: text/html;ntcharset="iso-8859-1"n";
$Msg.="Content-Transfer-Encoding: base64nn";
// html goes here
$Msg.=chunk_split(base64_encode($Html))."nn";
// end of IB
$Msg.="n--".$IB."--n";
// attachments
if($AttmFiles){
foreach($AttmFiles as $AttmFile){
$patharray = explode ("/", $AttmFile);
$FileName=$patharray[count($patharray)-1];
$Msg.= "n--".$OB."n";
$Msg.="Content-Type: application/octetstream;ntname="".$FileName.""n";
$Msg.="Content-Transfer-Encoding: base64n";
$Msg.="Content-Disposition: attachment;ntfilename="".$FileName.""nn";
//file goes here
$fd=fopen ($AttmFile, "r");
$FileContent=fread($fd,filesize($AttmFile));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$Msg.=$FileContent;
$Msg.="nn";
}
}
//message ends
$Msg.="n--".$OB."--n";
mail($To,$Subject,$Msg,$headers);
//syslog(LOG_INFO,"Mail: Message sent to $ToName <$To>");
}