HTML email attachments arrive as text

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
paulbedford
Forum Newbie
Posts: 1
Joined: Wed Apr 16, 2003 8:52 am
Location: South Africa

HTML email attachments arrive as text

Post by paulbedford »

I have some code that is supposed to retrieve information from a database, put it into an HTML page and email the entire HTML page as an attachment. Most of the code works fine except that the attachment arrives as ATT000054.txt or something similar instead of filename.htm which is what I want. The first few lines of the attachment contain the following:

Content-Type: text/html;
name="filename.html"

Content-Disposition: attachment;
filename="filename.html"

Content-Transfer-Encoding: 7bit
followed by the HTML.

Part of the code that sends the message is as follows:

Code: Select all

headers = "From: $candidate_row&#1111;first]$candidate_row&#1111;last]<$result_pers&#1111;email]>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Return-Path: <webmaster@somedomain.com>\n";
$headers .= "Content-Type: multipart/mixed;\n\t boundary="==adrufhyrtdsvvh=="\n";
$message = "This is a multipart message in MIME format.\n";
$message .= "--==adrufhyrtdsvvh==
$comments
--==adrufhyrtdsvvh==
Content-Type: text/html;\n\tname="$file_att"
Content-Disposition: attachment;\n\tfilename="$file_att"
Content-Transfer-Encoding: 7bit
$file_content
--==adrufhyrtdsvvh==--";
mail($to, $subject, $message, $headers);
$comments diplays in the body of the email as plain text which is what I want.
Has anybody got any idea what I've done wrong?
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Image Image
Post Reply