Php 通过邮件发送日历请求

Php 通过邮件发送日历请求,php,email,calendar,Php,Email,Calendar,我试图通过php代码实现日历请求邮件。我的代码如下: $to = "srimanta.chakraborty@fugenx.com"; $subject = "Training Registration"; $message = "Thank you for participating in the Technical Certification training program."; $location = "Conf"; //================== $headers = "Co

我试图通过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”文件一起转发。 我需要接受,暂定,拒绝,提出新的时间,日历选项以及邮件。 请指导我怎么做。 谢谢

在这里,尝试将单引号更改为双引号(“=>”)

这是因为丁格尔引号将转义\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);

不确定我会在你的代码中张贴什么是有效的电子邮件地址。考虑使用一个现代的PHP邮件库,比如PHPMailer或者SIFFTMALER,来处理你的附件。正如你现在看到的,滚动你自己的MIME是一个痛苦。实际上,上面的答案假设代码可以发送CaldReN~(i)我不知道如何通过EM发送日历。ail@@A将此单引号更改为双引号后,我遇到了以下问题:ORGANIZER;CN=“Corporate”“:mailto:srimanta12@gmail.com位置:UID:0400000008200E00074C5B7101A82E0080000006FC30E6 C39DC004CA782E0C002E01A81序列:0 DTSTAMP:20121228T002344结束:VEVENT结束:VCALENDA感谢您参加技术认证培训计划。另外,在标题部分,我收到了另一条消息,如“此消息中的额外换行符已删除”。我没有收到该电子邮件的任何接受链接或Tentavive链接。您的代码来自哪里?我不知道如何通过电子邮件发送日历,因为我在办公室,现在没有时间做研究:-)但是,我的下一个建议是检查您是否应该将$messaje放在$Headers中。此外,我想您可以尝试将所有\r\n改为\r\nOh….$messaje。“说明:您已注册该类\n”;you miss=在这里,对于上面的消息,我的意思是我认为$messaje应该放在$message中
$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);