Jump to content

attachments not viewing properly in Entourage email program

- - - - -

  • Please log in to reply
No replies to this topic

#1
obsurf

obsurf

    Newbie

  • Members
  • Pip
  • 1 posts
I have created the below code which processes an HTML web form, and then sends the data to a recipient. The problem is that the attachments involved, do not display correctly in the email program, Entourage for Macintosh. Instead, they show up as text inside the message, like this below:

"This is a multi-part message in MIME format.

--==frontier
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

The following person has applied online:

Name: tr
Phone: r
Email: tr@tk.com
Address: t
Educational Level: r
Additional Info:
How they heard of us:


--==frontier
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document;
name="testhey.docx"
Content-Disposition: attachment;
Content-Transfer-Encoding: base64

UEsDBBQABgAIAAAAIQDd/JU3ZgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0
VMtuwjAQvFfqP0S+Vomhh6qqCBz6OLZIpR9g7A1Y9Uv28vr7bgJEVQtBKuUSKVnvzOzsxIPR2pps
CTFp70rWL3osAye90m5Wso/JS37PsoTCKWG8g5JtILHR8PpqMNkESBl1u1SyOWJ44DzJOViRCh/
..."

I believe the problem lies in my code below, which is doing something which Entourage doesn't like. However, it works fine in gmail, yahoo mail, Outlook Express and android.

have any idea what is causing this?

Here is the code:

<?
$to=" ";
$subject="Online Application Received";
$from = stripslashes($_POST['fullname'])."<".stripslashes($_POST['email']).">";

// generate a random string to be used as the boundary marker
$mime_boundary="==frontier";


// now we'll build the message headers
$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";


$fullname= stripslashes( $_POST['fullname']);
$phone= stripslashes( $_POST['phone']);
$address= stripslashes( $_POST['address']);
$email= stripslashes( $_POST['email']);
$education= stripslashes( $_POST['education']);
$additional= stripslashes( $_POST['additional']);
$reference= stripslashes( $_POST['reference']);
$message="The following person has applied online: \n\n ";
$message.="Name: $fullname \n";
$message.="Phone: $phone \n";
$message.="Email: $email \n";
$message.="Address: $address \n";
$message.="Educational Level: $education \n";
$message.="Additional Info: $additional \n";
$message.="How they heard of us: $reference \n";




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


foreach($_FILES as $userfile){
// store the file information to variables for easier access
$tmp_name = $userfile['tmp_name'];
$type = $userfile['type'];
$name = $userfile['name'];
$size = $userfile['size'];


if (file_exists($tmp_name)){

if(is_uploaded_file($tmp_name)){


$file = fopen($tmp_name,'rb');

// read the file content into a variable
$data = fread($file,filesize($tmp_name));


fclose($file);


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


$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Disposition: attachment;\n" .
// " filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
}
}

$message.="--{$mime_boundary}--\n";
// now we just send the message
if (@mail($to, $subject, $message, $headers))
echo '<meta http-equiv="Refresh" content="0; URL=thanks.html">';
else
echo "Failed to send. Please contact us at: ";

?>




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users