vedel by mi niekto poradit ako to urobit tak aby mail bol v HTML a v prilohe bol len subor ktory chcem pripajat?
Kód: Vybrať všetko
function email($recipient,$massage,$subject,$from, $attachments=false){
$body = "Správa z webu www.xyz.com: \n"
. "Predmet: ".$subject."\n"
. "Mail: ".$recipient."\n"
. "Od: ".$from."\n\n"
. "Správa: \n".htmlspecialchars($massage)."\n\n";
$to = $recipient;
$subject = $subject;
$fromaddress = $from;
$name = "";
$mime_boundary = "----www.xyz.com----".md5(time());
$headers = "From: ".$from."\n";
$headers .= "Reply-To:".$from."\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$mime_boundary\"\n";
# -=-=-=- TEXT EMAIL PART
$message2 = "--$mime_boundary\n";
$message2 .= "Content-Type: text/plain; charset=utf-8\n";
$message2 .= "Content-Transfer-Encoding: 8bit\n\n";
$message2 .= strip_tags($body)."\n\n";
# -=-=-=- HTML EMAIL PART
$message2 .= "--$mime_boundary\n";
$message2 .= "Content-Type: text/html; charset=utf-8\n";
$message2 .= "Content-Transfer-Encoding: 8bit\n\n";
$message2 .= "<html>\n";
$message2 .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:14px; color:#666666;\">\n\n";
$message2 .= str_replace("<br />", "<br>", nl2br($body));
$message2 .= "\n</body>\n";
$message2 .= "</html>\n";
# -=-=-=- FINAL BOUNDARY
if ($attachments !== false)
{
for($i=0; $i < count($attachments); $i++)
{
if (is_file($attachments[$i]))
{
$fileatt = $attachments[$i];
$fileatt_type = "application/octet-stream";
$start= strrpos($attachments[$i], '/') == -1 ? strrpos($attachments[$i], '//') : strrpos($attachments[$i], '/')+1;
$fileatt_name = substr($attachments[$i], $start, strlen($attachments[$i]));
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$data = chunk_split(base64_encode($data));
$message2 .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
}
}
}
# -=-=-=- SEND MAIL
$mail_sent = @mail($recipient, $subject, $message2, $headers);
return $mail_sent;
}