Email attachments empty [SOLVED]
Posted: Fri Feb 04, 2005 8:36 am
Hello all,
I am writing a mail form which passes the form field results to the recipient as an HTML email and as a CVS attachment. I am using the script found here http://www.hollowearth.co.uk/tech/php/e ... hments.php as a basis of my script. So far I have been able to get the form information sent to myself along with a CSV attachment however when I open the attachment is is always blank. Does anyone have ideas as to why this is?
feyd | please use the formatting we provide
I am writing a mail form which passes the form field results to the recipient as an HTML email and as a CVS attachment. I am using the script found here http://www.hollowearth.co.uk/tech/php/e ... hments.php as a basis of my script. So far I have been able to get the form information sent to myself along with a CSV attachment however when I open the attachment is is always blank. Does anyone have ideas as to why this is?
Code: Select all
<?php
// this determines the recipient email based on the recipient name
if ($RecipientName == 'forrest') {
$Recipient = 'me@mydomain.com';
} elseif ($RecipientName == 'frazier') {
$Recipient = 'you@mydomain.com';
}
// email subject
$Subject = "Customer Request Form";
// mime for attaching attachment to email
$mime_boundary = "<<<--==+Xї".md5(time())."]";
$headers .= "From: $SendersName <$SendersEmail>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed;\r\n";
$headers .= " boundary="".$mime_boundary.""";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
$message .= "Content-Type: text/html; charset=iso-8859-1\r\n"; //specifies it is to be an html email
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= "\r\n";
$message .="
Dear $RecipientName, <br />
<br />
$SendersName has sent you an e-mail using your online contact form.<br />
<br />
<b>Message:</b> <br />
$Body <br />
<br />
<hr noshade="true" size="1" color="#000000" />
You can contact $SendersName at <a href="mailto:$SendersEmail">$SendersEmail</a> or just reply to this e-mail.";
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
// atachment info
$message .= "Content-Type: application/octet-stream;\r\n";
$message .= " name="filename.csv"\r\n";
$message .= "Content-Transfer-Encoding: quoted-printable\r\n";
$message .= "Content-Disposition: attachment;\r\n";
$message .= " filename="filename.csv"\r\n";
$message .= "\r\n";
$message .= $fileContent;
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
$ok = mail("$Recipient", "$Subject", $message, $headers);
// Message the user will see if the e-mail is succesfully sended :)
header("Location: $ThanksPage");
exit;
?>feyd | please use the formatting we provide