Problems with mail()
Posted: Tue Feb 01, 2011 3:44 pm
Hi at DevNetwork
I have a problem with the function mail(). Or proberly a problem with the data i put into the function.
I can't make it send mails to CC and BCC.
Here is my script
Everything works, except the CC and BCC
Any ideas?
Thanks!
I have a problem with the function mail(). Or proberly a problem with the data i put into the function.
I can't make it send mails to CC and BCC.
Here is my script
Code: Select all
// Mail content
$message = "dette er en test med æ ø å og Æ Ø Å";
$subject = "1 test med æ ø å og Æ Ø Å";
$file = $_SERVER['DOCUMENT_ROOT'] . str_replace("project_mail_data.php" ,"", $_SERVER["SCRIPT_NAME"] . $files[$i]);
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$name = basename($file);
$header = "From: DCP Postyr <dcp@postyr.dk>\r\n";
$header .= "Reply-To: dcp@postyr.dk\r\n";
$headers .= "CC: kdmcc@lortemail.dk\r\n";
$headers .= "BCC: kdmbcc@lortemail.dk\r\n";
$headers .= "\r\nX-Mailer: PHP/" . phpversion() . "\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".md5(uniqid(time()))."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".md5(uniqid(time()))."\r\n";
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= "--".md5(uniqid(time()))."\r\n";
$header .= "Content-Type: application/zip; name=\"".$filename."\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
$header .= $content."\r\n\r\n";
$header .= "--".md5(uniqid(time()))."--";
if (mail($to, $subject, $message, $header)) {
echo "mail send ... OK";
} else {
echo "mail send ... FEJL!";
}
Any ideas?
Thanks!