Help sending a Plain Text email Attatchment
| From: | Kevin Stone | Date: | Fri, 29 Mar 2002 00:01:17 +0000 |
| Subject: | Help sending a Plain Text email Attatchment | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-90611@lists.php.net to get a copy of this message | ||
For some reason this is not working. I do not have enough experience
with email headers to know why. Suffice to say it is not sending the
$message string as an attachment. Instead it is ending up in the
standard body of the email. And whatever ends up on the body is only a
fraction of what is stored in the $file string (containing the plain
text data to be attached). The code that I am using is almost directly
copied from Kevin Yanks, Email Attachment tutorial at
http://www.webmasterbase.com/article/679/82
I can only assume I am missing a critical step. Any help you can give
will be greatly appreciated.
--
Kevin Stone
Kevin@helpelf.com
//----------------------------------------------------------------------
-----
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .=
"\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
"boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$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" .
$file .
"\n\n";
$to = 'myemailaddress@mydomain.com';
$subject = 'test';
// Send the message
$result = @mail($to, $subject, $message, $headers);
if ($result)
{
echo "<p><font color=green>Mail sent! Yay
PHP!</font></p>";
}
else
{
echo "<p><font color=red>Mail could not be sent.
Sorry!</font></p>";
}
//----------------------------------------------------------------------
---------------