php电子邮件脚本不会生成HTML版本或附件扩展.出了什么问题


php email script does not produce an HTML version or attachment extension. what went wrong?

以下是(所有)代码:

<?php
/*
            WHITE SPACE MATTERS IN THIS DOCUMENT
*/
include("_php/ChromePhp.php");
    // define receiver of email
$to = "person@place.com";
    // define subject of email
$subject = "<--== KABAM!  HTML Email from WR! ==-->";
    // define message to send.  use /n for linebreaks
//$message = 'This is the message.  Read it.  Love it.';
    // create a boundary string.  it must be unique!
$uniqID = md5(date('r', time()));
    // define the headers. separated by 'r'n
$headers = "From: some dude" . "'r'n";
$headers .= "Reply-To: nobody" . "'r'n";
$headers .= "MIME-Version: 1.0" . "'r'n";
$headers .= "Content-Type: multipart/mixed; boundary='"PHP-mixed-".$uniqID."'""."'r'n";
    // read the attachment into a string, encode it and then
    // split it into smaller chunks
$attachment = chunk_split(base64_encode(file_get_contents('./_dox/pdftmp/emailTESTER.zip')));
    // define the body of the message
ob_start(); // turn on output buffering
?>
--PHP-mixed-<?php print $uniqID; ?>
Content-Type: multipart/alternative; boundary="PHP-alt-<?php print $uniqID; ?>
--PHP-alt-<?php print $uniqID; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
This is the TEXT email.
Nothing but pure text.  not really fun...
--PHP-alt-<?php print $uniqID; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<h1>This is the HTML test email.</h1>
<h3>Read it.  Love it.</h3>
<p>this is all HTML.  without any CSS, mind you...</p>
<?php include("_php/formEmail.php"); ?>
--PHP-alt-<?php print $uniqID; ?>--
--PHP-mixed-<?php print $uniqID; ?>
Content-Type: application/zip; name="emailTESTER.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
<?php print $attachment; ?>
--PHP-mixed-<?php print $uniqID; ?>--
<?php
    // copy current buffer contents into $message then delete
    // the contents of the output buffer
$message = ob_get_clean();
    // send the email
$mail_sent = @mail($to, $subject, $message, $headers);
    // display a message depending on mail_sent status
print  $mail_sent ? "Mail Sent: ".$uniqID : "Mail Failed: ".$uniqID;
?>

这就是电子邮件客户端中弹出的内容:(不呈现…)

This is the TEXT email.
Nothing but pure text.  not really fun...
--PHP-alt-a0d18dbf6c6ec8fb30c47adc84234c75Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<h1>This is the HTML test email.</h1>
<h3>Read it.  Love it.</h3>
<p>this is all HTML.  without any CSS, mind you...</p>

--PHP-alt-a0d18dbf6c6ec8fb30c47adc84234c75--

附件,而不是"emailTESTER.zip",只是"第2部分",没有扩展。如果我添加".zip",它将成为具有正确内容的正确存档(尽管命名错误)。。。

我反复检查了边界线,我相信它们设置正确。我唯一能想到的就是内容类型声明中的内容。。。但如果是的话,我对它可能是什么一无所知……我已经阅读了之前所有关于"PHP电子邮件HTML等等"的帖子,虽然它们提供了见解,但没有一篇涉及到我的两个奇怪的打嗝narf

所以。我错过了什么?为什么它不能正确/完全工作?

TIA。

WR!

不要重新发明轮子。使用现有的邮件类。PHPMailer非常出色。