为什么这个PHP邮件程序脚本无法使用HTML和附件? [重复]

Possible Duplicate:
How to send email with attachment using PHP?
PHP mail() attachment problems

I'm trying to implement this script: Send PHP HTML mail with attachments

The only thing I've modified in the script was the send-to address and the file. I'm trying to attach an .mp3 file instead of a .zip file - maybe this is the reason I'm getting unexpected results?

The .mp3 file is only 31kb

But when I receive the email, there is no attachment and no HTML formatting in the message.

The email message contains:

--PHP-mixed-a80d597fc7c02e67ff5be867c7a48bab
Content-Type: multipart/alternative; boundary="PHP-alt-a80d597fc7c02e67ff5be867c7a48bab"

--PHP-alt-a80d597fc7c02e67ff5be867c7a48bab
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello World!!!
This is simple text email message.

--PHP-alt-a80d597fc7c02e67ff5be867c7a48bab
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>

--PHP-alt-a80d597fc7c02e67ff5be867c7a48bab--

--PHP-mixed-a80d597fc7c02e67ff5be867c7a48bab
Content-Type: application/zip; name="attachment.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment

SUQzAwAAAAABIVRQRTEAAAAfAAAB//5DAGgAZQBlAHMAZQBDA.....

I am looking at this line in your mail:

Content-Type: application/zip; name="attachment.zip"

You are attaching a mp3 file, so your content type should be audio/mpeg3 and the filename should be according to whatever you are sending.

Content-Type: audio/mpeg3; name="somefile.mp3"

Also - be careful of the 64 bit encoding. You have to encode the mp3 in order to mail it, because you will again get unexpected results if you don't.