Jump to content

mail() header issue (again!)


brentar

Recommended Posts

I have an online application form.  I tested and wrote it on a windows machine.. once it switched to the "live" server which is Linux, it all went downhill.  There should always be 2 attachments sent out and any attachments the user added.  Only one comes through properly and the rest come up garbled.  The files upload to the server fine...  must be a header problem or a mime issue.  Any thoughts????  Thanks in advance.  I am guessing it is something silly between windows/linux.  I just can't find it.  I also told the company to switch so that both servers are the same!

Here are the main pieces of code.

 

$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$infoFile_type = "application/octet-stream";// File Type
$file = $_FILES['uploadedfile']['name'][0];
$files = fopen($fileatt,'rb');
$data = fread($files,filesize($fileatt));
fclose($files);

$data = chunk_split(base64_encode($data));

$email_from = "[email protected]"; // Who the email is from

$headers = "From: " . $email_from . "\n";

$headers .= "MIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"\n";

// $headers .= "From: ".$email_from;

$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";

$message .= "Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
$message .= "--{$mime_boundary}\n";
unset($data);
unset($file);
unset($fileatt);
unset($fileatt_type);
unset($fileatt_name);

Link to comment
https://forums.phpfreaks.com/topic/155526-mail-header-issue-again/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.