HELP!! Mail and attachments
| From: | Tym Rehm | Date: | Fri, 27 Apr 2001 13:46:16 +0000 |
| Subject: | HELP!! Mail and attachments | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-50622@lists.php.net to get a copy of this message | ||
I have been trying to get this to work for days and I'm confused. I want to
attach a Word document to an email. I found this code on php.net and I'm
trying to modify it to work. I get the email sent, the attached Word
document is filled with junk and not the document I'm trying to send.
Here is the code and sorry for the large email.
<?php
$border="--==================_856811060==_";
#/* recipients */
#$recipient .= "Mary <mary@u.college.edu>" . ", "; #//note the comma
#$recipient .= "Kelly <kelly@u.college.edu>" . ", ";
#$recipient .= "ronabop@php.net";
$recipient = "trehm@comdotnetworking.com";
#/* subject */
$subject = "Birthday Reminders for August";
#/* message */
$message .= "$border\n";
$message .= "Content-Type: text/plain; charset=us-ascii;format=flowed\n";
$message .= "The following email includes a formatted ASCII table\n";
$message .= "Day \t\tMonth \t\tYear\n";
$message .= "3rd \t\tAug \t\t1970\n";
$message .= "17rd\t\tAug \t\t1973\n";
$message .= "$border\n";
#$message .= "Content-Type: application/msword; name=\"/mail/Ftp\ User\
Info.doc\"\n";
#$message .= "Content-Transfer-Encoding: base64\n";
#$message .= "Content-Disposition: attachment; filename=\"/mail/Ftp\ User\
Info.doc\"\n";
#$message .="$border\n";
#/* you can add a stock signature */
$message .= "--\r\n"; //Signature delimiter
$message .= "Birthday reminder copylefted by public domain";
#/* additional header pieces for errors, From cc's, bcc's, etc */
$headers .= "From: Birthday Reminder <birthday@php.net>\n";
$headers .= "X-Sender: <birthday@php.net>\n";
$headers .= "X-Mailer: PHP\n"; // mailer
$headers .= "X-Priority: 1\n"; // Urgent message!
$headers .= "Return-Path: <birthday@php.net>\n"; // Return path for errors
# I added this code
$headers .= "Mime-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$border\"\n";
#$headers .= "Content-Type: text/plain; charset=us-ascii;format=flowed\n";
$headers .= "Content-Type: application/msword; name=\"Ftp\ User\
Info.doc\"\n";
$headers .= "Content-Transfer-Encoding: base64\n";
$headers .= "Content-Disposition: attachment; filename=\"Ftp\ User\
Info.doc\"\n";
#/* If you want to send html mail, uncomment the following line */
#$headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
#$headers .= "cc:birthdayarchive@php.net\n"; // CC to
#$headers .= "bcc:birthdaycheck@php.net, birthdaygifts@php.net\n"; // BCCs
to
#$headers .= "cc:trehm@fitnessquest.com\n"; // CC to
#$headers .= "bcc:trehm@comdotnetworking.com,
telathos@comdotnetworking.com\n"; // BCCs to
#/* and now mail it */
mail($recipient, $subject, $message, $headers);
print "<html><head><title>Mail</title></head>\n";
print"<body>\n";
print "<p>Mail Sent?\n";
print"</body></html>\n";
?>
Thanks!!!!!!!!