In reply to:
When I send the message with attachment using the script on my server via firefox, and receive that message in gmail, it works fine.
When I send the same attachment using the same script on dreamhost via firefox and receive in gmail, it shows as base64 in the body instead of attached.
Finally figured out what the problem was - another programmer error.
And once again the problem you have is due to you adding linebreaks to the end of strings. Here is the relevant code from your version:
$from = "From: $name ($email)\n" ;
$headers = $from;
...
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
You added the linebreak at the end of the assignment to $from. By doing so you broke the header section by adding a blank line. ie,
From: name <email>
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="boundary";
Personally, this is how I would handle things:
function add_linebreak($str) {
// Add the correct linebreak sequence to a string
return $str . "\r\n";
}
// Specify the header lines as an array - without linebreaks!
$headers = array(
'From: name <email>',
'MIME-Version: 1.0',
'Content-Type: mixed;',
' boundary="boundary"'
);
// Add linebreaks and join into a single string
$header_section = implode(array_map('add_linebreak', $headers));This way the need to put special characters in certain spots is hard-wired into the logic instead of a series of convoluted quoted-strings.
openvein.org -//- Edited by Atropos7 on 01/25/09 10:34 PM (server time).