Witam
Sciagnalem z jakiejś strony taką oto funkcje do wysyłania formularzy z html-em :
<?php
function send_mail($emailaddress, $emailsubject, $body, $type = "html", $fromaddress = "mail@mail.com", $namefrom = "Site name")
{
$eol="\n";
# Common Headers
$headers .= "From: $namefrom <$fromaddress>".$eol;
$headers .= "Reply-To: $namefrom <$fromaddress>".$eol;
$headers .= "Return-Path: $namefrom <$fromaddress>".$eol;
// these two to set reply address
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters
# Boundry for marking the split & Multitype Headers
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
$msg = "";
# Setup for text OR html
$msg .= "Content-Type: multipart/alternative".$eol;
# Text Version
if($type == "text") {
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: text/plain; charset=UTF-8".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol;
}
# HTML Version
else if($type == "html") {
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: text/html; charset=UTF-8".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol;
$msg .= $body.$eol.$eol;
}
$msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two eol's for better security. see Injection.
if ( mail($emailaddress, $emailsubject, $msg, $headers) ) return 1; else return 0;
}
?>
a następnie wywołuje ją w taki oto sposób :
<?php
$mail_message .= "<b>ID :</b> ".$mail_fromid."<br />";
$mail_message .= "<b>od :</b> ".$mail_frommail."<br />";
$mail_message .= "<b>IP :</b> ".$mail_ip."<br /><br />".$_POST['mail_message'];
send_mail(MAIL_RECEIVER, $mail_topic, $mail_message, "text" ,$mail_frommail, "Binfo.com - kontakt")
?>
niestety kiedy mail dochodzi, wszystki jest wporządku oprocz treści...w ww. przypadku mail dochodzi bez treści natomiast jeśli przy wywoływaniu funkcji send_mail(), zamiast $mail_message podam $_POST['mail_message'] to wszystko łącznie z treścią maila działa ok.
Mało tego, jeśli wywołam sobie zmienną $mail_message za pomocą echo, wszystko elegancko się pokazuje. Mysle więc, że to jakiś problem związany z zasadami, którymi rządzi się zawartość emaila...
Pozdrawiam i proszę o pomysły
Ten post edytował Bajki 28.08.2008, 08:34:06