我通过电子邮件发送日历邀请,但我希望它自动被接受。如何使电子邮件日历邀请自动接受(PHP)?
有什么我可以改变我的代码?我的代码如下所示:
功能sendIcalEmail($名字,姓氏$,$电子邮件,$ meeting_date,$ MEETING_NAME,$ meeting_duration){
$from_name = “My Name”;
$from_address = “[email protected]”;
$subject = “Meeting Booking”; //Doubles as email subject and meeting subject in calendar
$meeting_description = “Here is a brief description of my meeting\n\n”;
$meeting_location = “My Office”; //Where will your meeting take place
//Convert MYSQL datetime and construct iCal start, end and issue dates
$meetingstamp = strtotime($meeting_date . ” UTC”);
$dtstart= gmdate(”Ymd\THis\Z”,$meetingstamp);
$dtend= gmdate(”Ymd\THis\Z”,$meetingstamp+$meeting_duration);
$todaystamp = gmdate(”Ymd\THis\Z”);
//Create unique identifier
$cal_uid = date(’Ymd’).’T’.date(’His’).”-”.rand().”@mydomain.com”;
//Create Mime Boundry
$mime_boundary = “—-Meeting Booking—-”.md5(time());
//Create Email Headers
$headers = “From: “.$from_name.” <”.$from_address.”>\n”;
$headers .= “Reply-To: “.$from_name.” <”.$from_address.”>\n”;
$headers .= “MIME-Version: 1.0\n”;
$headers .= “Content-Type: multipart/alternative; boundary=\”$mime_boundary\”\n”;
$headers .= “Content-class: urn:content-classes:calendarmessage\n”;
//Create Email Body (HTML)
$message .= “–$mime_boundary\n”;
$message .= “Content-Type: text/html; charset=UTF-8\n”;
$message .= “Content-Transfer-Encoding: 8bit\n\n”;
$message .= “<html>\n”;
$message .= “<body>\n”;
$message .= ‘<p>Dear ‘.$firstname.’ ‘.$lastname.’,</p>’;
$message .= ‘<p>Here is my HTML Email/Used for Meeting Description</p>’;
$message .= “</body>\n”;
$message .= “</html>\n”;
$message .= “–$mime_boundary\n”;
//Create ICAL Content (Google rfc 2445 for details and examples of usage, beware of adding tabs)
$ical = ‘BEGIN:VCALENDAR
PRODID: - //微软公司的Outlook // 11.0 MIMEDIR // EN 版本:2.0 方法:发布 BEGIN:VEVENT 主办单位:MAILTO: '$ FROM_ADDRESS' DTSTART: '$为dtstart。' DTEND: '$ DTEND。' 位置:”。 $ meeting_location。' TRANSP:OPAQUE SEQUENCE:0 UID: '$ cal_uid' DTSTAMP: 说明 '$ todaystamp。': 内容 '$ meeting_description。': PRIORITY '$主题。':5 类:public END:VEVENT END :VCALENDAR“;
$message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST;charset=utf-8\n';
$message .= 'Content-Transfer-Encoding: 8bit\n\n';
$message .= $ical;
//SEND MAIL
$mail_sent = @mail($email, $subject, $message, $headers);
if($mail_sent) {
return true;
} else {
return false;
}
}