通过邮件发送日历请求

2024-01-11

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

$to = "[email protected] /cdn-cgi/l/email-protection";
$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:[email protected] /cdn-cgi/l/email-protection";
$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”文件一起转发。 我需要邮件中的“接受”、“暂定”、“拒绝”、“提议新时间”、“日历”选项。 请指导我如何做到这一点。 谢谢。


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

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

这是因为 dingle 引号会转义 \r 和 \n
参考 http://php.net/manual/en/language.types.string.php#language.types.string.syntax.single

Update
最后,我按照下面的建议进行操作并更改您的标题,至少,它对我有用。

$to = "[email protected] /cdn-cgi/l/email-protection";
$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:[email protected] /cdn-cgi/l/email-protection\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);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

通过邮件发送日历请求 的相关文章

随机推荐