email - PHP Mail Headers -


essentially i'm trying attach file email i'm sending out. simple enough, right? reason or not following code (presumably because of headers). can help?

thanks in advance!!

$subject = "file ".date("ymd"); $message = "none"; $filename = "test.csv";  $content = chunk_split(base64_encode(file_get_contents($filename))); $uid = md5(uniqid(time())); $name = basename($file);  $header .= "mime-version: 1.0\r\n"; $header .= "from: noreply@x.com\r\n"; $header .= "reply-to: noreply@x.com\r\n";   $header .= "content-type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "this multi-part message in mime format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "content-type:text/plain; charset=iso-8859-1\r\n"; $header .= "content-transfer-encoding: 7bit\r\n\r\n"; $header .= $message."\r\n"; $header .= "--".$uid."\r\n"; $header .= "content-type: text/csv; 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 .= "--".$uid."\r\n"; //echo $header;  if (mail($to_email, $subject, $message, $header)) {     echo "mail send ... ok";  } else {     echo "mail send ... error!"; } 

and error:

warning: mail() [function.mail]: bad parameters mail() function, mail not sent.

please please please don't build own mime emails. use phpmailer or swiftmailer, you. can replace entire script 5 or 6 lines of code.

and best of all, they'll give far better error messages/diagnostics pathetically stupid mail() function ever will.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -