Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

email headers

the mail() function

Moderators: macek, egami, gesf

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?
<?php
$to = "drunkbrokehappy@gmail.com";
$from = "drunkbrokehappy@gmail.com";
$title = $_POST['title'];
$story = $_POST['story'];
$message = "Title: ".$title;
$message .= "Story: ".$story;
$subject = "NEW SUBMISSION";
$temp_name = $_FILES['file']['tmp_name'];

if(!empty($_FILES['file']['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);
header('Location: http://www.drunkbrokehappy.com/thankyou');
exit();

}




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

Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.