我尝试从我的yahoo帐户向我的Gmail帐户发送Ical格式日历活动的电子邮件。但它没有在我的雅虎帐户上发送任何日历事件。它在本地服务器上工作正常,但在Live服务器上它没有发送电子邮件。 我做了一些研究似乎雅虎日历配置不是完全支持的功能。 所以请帮助,提前谢谢你。 这是我的代码在本地服务器上正常工作。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>iCal Test</title>
</head>
<body>
<?php
$firstname = "Bindiya";
$lastname = "Rose";
$email = "bindiya@gmail.com";
$event_date = "2010-07-06 13:40:00"; //mysql format
$event_name = "Hello";
$event_duration = 3600;
$result = sendIcalEmail($firstname,$lastname,$email,$event_date,$event_name,$event_duration);
if($result) {
echo "Email sent successfully.";
} else{
echo "A problem occurred sending email";
}
?>
</body>
</html>
<?php
function sendIcalEmail($firstname,$lastname,$email,$event_date,$event_name,$event_duration) {
$from_name = "Bindiya";
$from_address = "bindiya@yahoo.com";
$subject = "event Booking";
$event_description = "Here is a brief description of my event\n\n";
$event_location = "My Office";
$message = "Content-Type: text/calendar;method=REQUEST\n";
$eventstamp = STRTOTIME($event_date . " UTC");
$dtstart= GMDATE("Ymd\THis\Z",$eventstamp);
$dtend= GMDATE("Ymd\THis\Z",$eventstamp+$event_duration);
$todaystamp = GMDATE("Ymd\THis\Z");
$cal_uid = DATE('Ymd').'T'.DATE('His')."-".RAND()."@gmail.com";
$mime_boundary = "----Meeting Booking----".MD5(TIME());
$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";
$headers .= "Content-Type: text/html; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n\n";
$ical = 'BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
ORGANIZER:MAILTO:'.$from_address.'
DTSTART:'.$dtstart.'
DTEND:'.$dtend.'
LOCATION:'.$event_location.'
TRANSP:OPAQUE
SEQUENCE:0
UID:'.$cal_uid.'
DTSTAMP:'.$todaystamp.'
DESCRIPTION:'.$event_description.'
SUMMARY:'.$subject.'
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR';
$message .= 'Content-Type: text/calendar;method=REQUEST\n';
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= $ical;
$mail_sent = MAIL( $email, $subject, $message, $headers );
if($mail_sent) {
return true;
} else {
return false;
}
}
?>