3

我正在尝试通过我的 php 代码实现日历请求邮件。我的代码是这样的:

$to = "srimanta.chakraborty@fugenx.com";
$subject = "Training Registration";
$message = "Thank you for participating in the Technical Certification training program.";
$location = "Conf";
//==================
$headers = "Content-Type:text/calendar; Content-Disposition: inline; charset=utf-8;";
$headers .= "Content-Type: text/plain;charset=utf-8";
$messaje = "BEGIN:VCALENDAR";
$messaje .= "VERSION:2.0";
$messaje .= "PRODID:PHP";
$messaje .= "METHOD:REQUEST";
$messaje .= "BEGIN:VEVENT";
$messaje .= "DTSTART:20121223T171010Z";
$messaje .= "DTEND:20121223T191010Z";
$messaje . "DESCRIPTION: You have registered for the class";
$messaje .= "SUMMARY:Technical Training";
$messaje .= "ORGANIZER; CN=\"Corporate\":mailto:jayashree.g@fugenx.com";
$messaje .= "Location:" . $location . "";
$messaje .= "UID:040000008200E00074C5B7101A82E00800000006FC30E6 C39DC004CA782E0C002E01A81\n";
$messaje .= "SEQUENCE:0\n";
$messaje .= "DTSTAMP:".date('Ymd').'T'.date('His')."\n";
$messaje .= "END:VEVENT\n";
$messaje .= "END:VCALENDAR\n";
$headers .= $messaje;
mail($to, $subject, $message, $headers);

通过这段代码,我收到了邮件,但不是日历请求格式。此外,邮件已连同附件“Training Registration.ics”文件一起转发。我需要接受、暂定、拒绝、建议新时间、日历选项以及邮件。请指导我如何做到这一点。谢谢。

4

1 回答 1

3
$headers = 'Content-Type:text/calendar; Content-Disposition: inline; charset=utf-8;\r\n';

在这里,尝试将单引号改为双引号('=>")

这是因为 dingle 引号会转义 \r 和 \n
参考

更新
最后,我按照下面的建议更改您的标题,至少它对我有用。

$to = "srimanta.chakraborty@fugenx.com";
$subject = "Training Registration";
$message = "Thank you for participating in the Technical Certification training program.\r\n\r\n";
$location = "Conf";
//==================
$headers .= "MIME-version: 1.0\r\n";
$headers .= "Content-class: urn:content-classes:calendarmessage\r\n";
$headers .= "Content-type: text/calendar; method=REQUEST; charset=UTF-8\r\n";
$messaje = "BEGIN:VCALENDAR\r\n";
$messaje .= "VERSION:2.0\r\n";
$messaje .= "PRODID:PHP\r\n";
$messaje .= "METHOD:REQUEST\r\n";
$messaje .= "BEGIN:VEVENT\r\n";
$messaje .= "DTSTART:20121223T171010Z\r\n";
$messaje .= "DTEND:20121223T191010Z\r\n";
$messaje .= "DESCRIPTION: You have registered for the class\r\n";
$messaje .= "SUMMARY:Technical Training\r\n";
$messaje .= "ORGANIZER; CN=\"Corporate\":mailto:jayashree.g@fugenx.com\r\n";
$messaje .= "Location:" . $location . "\r\n";
$messaje .= "UID:040000008200E00074C5B7101A82E00800000006FC30E6 C39DC004CA782E0C002E01A81\r\n";
$messaje .= "SEQUENCE:0\r\n";
$messaje .= "DTSTAMP:".date('Ymd').'T'.date('His')."\r\n";
$messaje .= "END:VEVENT\r\n";
$messaje .= "END:VCALENDAR\r\n";
$message .= $messaje;
mail($to, $subject, $message, $headers);
于 2012-12-28T07:15:48.133 回答