PHP 不支持日历消息

Not supported calendar message with PHP

首先,我想说我是计算机的初学者。

我正在尝试编写一些代码,自动发送包含 ics 格式的新事件的邮件。 我在 Internet 上找到了一些代码示例。

这是我的代码

$desc= 'Rendez-vous dans le cadre de la résolution du ticket'.$ticket_id;
$headers = 'Content-Type:text/calendar; Content-Disposition: inline; charset=utf-8;\r\n';
$headers .= "Content-Type: text/plain;charset=\"utf-8\""; #EDIT: TYPO
$message = "BEGIN:VCALENDAR
                            VERSION:2.0
                            PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
                            METHOD:REQUEST
                            BEGIN:VEVENT
                            UID:" . md5(uniqid(mt_rand(), true)) . "example.com
                            DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z
                            DTSTART:".$startdate."T".$startTime."00Z
                            DTEND:".$enddate."T".$endTime."00Z
                            TRANSP:OPAQUE
                            SEQUENCE:0
                            SUMMARY:".$subject."
                            ORGANIZER;CN=".$organizer.":mailto:".$organizer_email."
                            LOCATION:".$location.', '.$site."
                            DESCRIPTION:".$desc."
                            PRIORITY:5
                            X-MICROSOFT-CDO-IMPORTANCE:1
                            CLASS:PUBLIC
                            ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:".$participant_email_1."                     
                            END:VEVENT
                            END:VCALENDAR";
$headers .= $message;
mail($participant_email_1, $subject, $message, $headers);   

每个变量都已经过验证并且工作正常。正如我在一些讨论中看到的,组织者邮件与邮件发件人相同。

但是当我收到邮件时,outlook 说可以"not supported calendar message.ics"。这是message.ics的内容:

BEGIN:VCALENDAR
                            VERSION:2.0
                            PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
                            METHOD:REQUEST
                            BEGIN:VEVENT
                            UID:91090dc834f3536fc3f37af82c1abe3aexample.com
                            DTSTAMP:20160920T142802Z
                             DTSTART:20160923T100000Z
                            DTEND:20160923T12000Z
                            TRANSP:OPAQUE
                            SEQUENCE:0
                            SUMMARY:test
                            ORGANIZER;CN=Marguerite Duras:mailto:example.example@example.example.com
                            LOCATION:Bordeaux, test
                            DESCRIPTION:Rendez-vous dans le cadre de la résolution du ticket17
                            PRIORITY:5
                            X-MICROSOFT-CDO-IMPORTANCE:1
                            CLASS:PUBLIC
                            ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:example.example@example.example.com                      
                            END:VEVENT
                            END:VCALENDAR

我更改了邮件地址,因为这是我的专业地址... 有谁知道这里出了什么问题? 对不起,近似英语,我是法语,外语很差...

非常感谢您的帮助!

每个 iCalendar 行不得以空格开头。删除每行开头的所有空格,如下所示:

$message = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
METHOD:REQUEST
...
END:VCALENDAR";