PHP mail()用iCalendar发送原始电子邮件

时间:2012-11-16 15:37:04

标签: php windows email icalendar

我希望能够发送多部分/替代电子邮件(特别是文本/日历编码项目,以便outlook,gmail等打开他们的菜单以便与附加的约会进行交互(允许用户添加)电子邮件服务器是一个不同的盒子,显然我是通过匿名SMTP发送的。以下是传递给php 5.3.6 mail()方法的标题和消息:

From: TestNet
Reply-To: TestNet
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="--Meeting Booking--fec0d81281514f7f839dc4cf0c117f64"
Content-class: urn:content-classes:calendarmessage
--Meeting Booking--fec0d81281514f7f839dc4cf0c117f64
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit



Dear Robert Burnham,

Here is my HTML Email / Used for Meeting Description



--Meeting Booking--fec0d81281514f7f839dc4cf0c117f64
Content-Type: text/calendar;name="meeting.ics";method=REQUEST;charset=utf-8
Content-Transfer-Encoding: 8bit

BEGIN:VCALENDAR 
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN 
VERSION:2.0 
METHOD:PUBLISH 
BEGIN:VEVENT 
ORGANIZER:MAILTO:test@test.net 
DTSTART:20121206T134000Z 
DTEND:20121206T144000Z 
LOCATION:My Office 
TRANSP:OPAQUE 
SEQUENCE:0 
UID:20121116T092255-9178@mydomain.com 
DTSTAMP:20121116T152255Z 
DESCRIPTION:Here is a brief description of my meeting


SUMMARY:Meeting Booking 
PRIORITY:5 
CLASS:PUBLIC 
END:VEVENT 
END:VCALENDAR

电子邮件发送成功,但我发现我传入的$ message被视为原始HTML(以下内容显示在电子邮件的实际正文中):

--Meeting Booking--b37b5edb86b3e7047ce15b2b348159d7
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<html>
<body>
<p>Dear Robert Burnham,</p><p>Here is my HTML Email / Used for Meeting Description</p>
</body>
</html>
--Meeting Booking--b37b5edb86b3e7047ce15b2b348159d7
Content-Type: text/calendar;name="meeting.ics";method=REQUEST;charset=utf-8\nContent-Transfer-Encoding: 8bit\n\nBEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
ORGANIZER:MAILTO:mailer@personalhealthsurvey.net
DTSTART:20121206T134000Z
DTEND:20121206T144000Z
LOCATION:My Office
TRANSP:OPAQUE
SEQUENCE:0
UID:20121116T092814-12916@mydomain.com
DTSTAMP:20121116T152814Z
DESCRIPTION:Here is a brief description of my meeting


SUMMARY:Meeting Booking
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR

1 个答案:

答案 0 :(得分:0)

作为最后的跟进,我让我自己开始工作,但是拥有oberron的链接:Here会让它变得更容易。话虽这么说,我最终取消了我的所有工作,故意“打破”iCalendar附件,以便它不会被outlook识别。好像Outlook的HTML解析不够糟糕(因为它使用了内置于Microsoft Word中的相同HTML解析器),当识别出“有效”的iCalendar会议附件时,解析器会陷入一种令人难以置信的基本模式,我无法工作周围。 HTML解析,特别是去了...这显然是预期的功能(当您在Outlook中创建电子邮件并附加事件时,所有 html编辑相关的按钮/功能消失对于那条消息。

最后,可以容忍的HTML格式是值得用户自己点击iCalendar附件。