English 中文(简体)
multipart/mixed email. Comes with empty body. What s wrong?
原标题:

sending an email:

From: <...>
X-Mailer: SnowBoss
Reply-To: <...>
X-Priority: 3 (Normal)
Message-ID: <248.20091210135259@snowman2010.com>
To: <...>
Subject: =?UTF-8?B?0JzQntCZIFNVQkpFQ1Q=?=
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----------A4D921C2D10D7DB"

This is a multi-part message in MIME format.

----------A4D921C2D10D7DB
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

MY TEXT
----------A4D921C2D10D7DB
Content-Type: text/html;
charset=utf-8
Content-Transfer-Encoding: 8bit

<html><b>BOLD</b></html>
----------A4D921C2D10D7DB
.

<250 Data received OK. //server response

and it comes with empty body. This only happens with multipart/mixed content (tried multipart/alternative - same story)

最佳回答

As Tomasz mentioned, the line where you are using the boundary, you must have two hyphen at the beginning of your boundary separarator. Check the following:

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="frontier"

This is a message with multiple parts in MIME format.
--frontier
Content-Type: text/plain

This is the body of the message.
--frontier
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64

PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg
Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==
--frontier--

Also notice that at the last boundary, you have to put another two hyphens to indicate that it s the end.

Example taken from Wikipedia, see here.

问题回答

I guess you may have boundary set wrong.

The boundary should look like

Content-Type: multipart/alternative; boundary="--------A4D921C2D10D7DB"

meaning - contain two less - characters. See the source of any email.

The mail ending boundary - on the other hand - should probably look like

----------A4D921C2D10D7DB--

(again, see the source of any mail message. Or read the RFC, of course :)).

I encourage you to use exisitng mailer classes, like Swift Mailer or PHPMailer. Why reinvent the wheel?

I guess you meant the line "This is a multi-part message in MIME format." as the body in the pasted snippet of the content. It depends on the email client whether it renders the body or not when the content type is set as mimepart/alternatie or mimepart/mixed. The body parts get displayed my almost all the clients.





相关问题
Angle brackets in php

I want to store angle brackets in a string in PHP because i want to eventually use mail() to send an HTML email out. The following is the code that doesn t seem to work. while(...) { $msg .= "<...

authlogic auto_register feature using my options

I have auto registration working with authlogic using gaizka s version of authlogic_openid which I found on Github since pelle s original addition of the feature seemed to cause issues. http://...

Zend 邮件问题,涉及外国char子+ com子

泽斯德邮局在名称被定为具有外国性质(如“保”)和 com(”)的物品时,就放弃了一种例外(因为邮局(邮局)退回假)。 重新提出以下守则。

How to track an email in Java?

How I can track an email? I m using java on the server side for sending emails. I want to track whether it is delivered , opened, etc... How I can do that ?

Web Link in a mail is not rendering as link in yahoo

string from = "abc@gmail.com"; string to = "xyz@gmail.com,xyz@yahoo.co.in"; string password="abcxyz"; MailMessage mail = new System.Net.Mail.MailMessage(); mail.To.Add(to); mail.From = new ...

SharePoint - Approaching Website Storage Limit Email

How can i go about changing the distribution list as well as the email text for the email that goes out to site collection admin when a site collection approaches it s size limit? Thanks for your ...

How to create an email mailing list

Im creating a coming soon page for a website im developing, and im adding an option for the user to enter their email address so we can email them when the site is up. How do I do this?

CCNet email does not include MSBuild results

We re using CCNet 1.4.4.83 but when an MSBuild task fails, we don t get the MSBuild results (i.e. missing file or whatever reason the compile failed) in the email notification. I do see the build ...

热门标签