1

我正在尝试通过我的 php 代码发送日历请求邮件。我收到了邮件和日历。但是我的开始日期有问题。如何根据海湾标准时间配置开始日期。现在我根据格林威治标准时间得到,虽然我没有提到任何地方。简而言之,如果我将在上午 7 点发送请求,那么在开始日期它将显示上午 11 点。我的代码是这样的:

$dtstart = $start_date_conf;

$dtend=$end_date_conf;

$todaystamp = date("Ymd\THis\Z");

//Create unique identifier
$cal_uid = date('Ymd').'T'.date('His')."-".rand()."@fugenx.com";

//Create Mime Boundry
$mime_boundary = "----Bespot 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>'.$messagess.'</p>';
$message .= '<p></p><p></p>';
$message .= '<p><b>Thanks & Regards,:</b></p>';
$message .= '<p>'.$full_name.'</p>';
$message .= '<p>'.$full_address.'</p>';
$message .= '<p>'.$email_address.'</p>';
$message .= '<p>'.$mobile_number.'</p>';

$message .= "</body>\n";
$message .= "</html>\n";
$message .= "--$mime_boundary\n";

//Create ICAL Content (Google rfc 2445 for details and examples of usage) 
$ical =    "BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
ORGANIZER:MAILTO:".$from_address."
DTSTART:".$dtstart."
DTEND:".$dtend."
LOCATION:".$meeting_location."
TRANSP:OPAQUE
SEQUENCE:0
UID:".$cal_uid."
DTSTAMP:".$todaystamp."
DESCRIPTION:".$meeting_description."
SUMMARY:".$subject."
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR";   


$message .= "Content-Type: text/calendar;method=REQUEST;charset=utf-8\n";

//$message .= "Content-Type: text/calendar;name=\"meeting.ics\";method=REQUEST\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= $ical;            

//SEND MAIL
$mail_sent = @mail( $email, $subject, $message, $headers );
4

1 回答 1

1

请参阅 RFC5545,您需要添加一个 vtimezone 组件以将 TZID 引用到它

参数名称: TZID

当指定了 DATE-TIME 或 TIME 值类型并且值既不是 UTC 也不是“浮动”时间。未能在 iCalendar 对象中包含和遵循 VTIMEZONE 定义可能会导致对任何给定位置的本地时间的理解不一致。

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
METHOD:REQUEST
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Asia/Qatar
BEGIN:STANDARD
DTSTART:20081102T090000
TZOFFSETFROM:+0300
TZOFFSETTO:+0300
TZNAME:CST
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
ORGANIZER:MAILTO:mailto@organiser.net
DTSTART;TZID=Asia/Qatar:20130104T090000
DTEND;TZID=Asia/Qatar:20130104T100000
LOCATION:meeting_location
TRANSP:OPAQUE
SEQUENCE:0
UID:cal_uid
DTSTAMP:20130104T224617Z
DESCRIPTION:meeting_description
SUMMARY:subject
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
于 2013-01-04T20:56:16.117 回答