email headers

the mail() function

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 2
Joined: Sun Feb 26, 2012 8:59 pm

email headers

Postby knot929 » Tue Feb 28, 2012 6:49 pm

I created this code to send an image in an attachment but i get this error: Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in /home/content/83/8940083/html/send-email-form.php on line 36
Is something wrong with my headers?
$to = "";
$from = "";
$title = $_POST['title'];
$story = $_POST['story'];
$message = "Title: ".$title;
$message .= "Story: ".$story;
$subject = "NEW SUBMISSION";
$temp_name = $_FILES['file']['tmp_name'];


// store file name
$file_name = $_FILES['file']['name'];
$file = $temp_name;
$content = chunk_split(base64_encode(file_get_contents($file)));
$uid = md5(uniqid(time()));

//standard mail headers
$headers = "From: ".$from."\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$headers .= "This is a multi-part mesage in MIME format.\r\n";
//plain text part
$headers .= "--".$uid."\r\n";
$headers .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$headers .= $message."\r\n\r\n";

//file attachment
$headers .= "--".uid."\r\n";
$headers .= "Name: ".$tmp_name."\r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n";
$headers .= $content."\r\n\r\n";
//send the email
mail($to, $subject, $message, $headers);

} else {
mail($to, $subject, $message);



Return to “PHP coding => Mail”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest