如同在描述的标题中,我试图创建一个ical元素并通过gmail smtp将其发送到邮箱。这是我的代码的样子:
include_once ("Mail/Mail.php");
include_once ("Mail/mime.php");
$ical = 'BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
PRODID:-//TITLE//COMPANY//DE
BEGIN:VEVENT
SUMMARY:' . $company. '
UID:' . $id . '
STATUS:CONFIRMED
DTSTART:' . $startdate . '00
DTEND:' . $enddate . '00
DESCRIPTION:' . $description . '
LOCATION:' . $location . '
END:VEVENT
END:VCALENDAR';
$hdrs = array (
'From' => $from_name . ' <' . $from_address . '>',
'Subject' => $subject,
);
$textparams = array (
'charset' => 'utf-8',
'content_type' => 'text/html',
'encoding' => 'base64'
);
$calendarparams = array (
'charset' => 'utf-8',
'content_type' => 'text/calendar;method=PUBLISH',
'encoding' => 'base64',
);
$email = new Mail_mimePart ( '', array (
'content_type' => 'multipart/mixed'
) );
$textmime = $email->addSubPart ( $message, $textparams );
$htmlmime = $email->addSubPart ( $ical, $calendarparams );
$final = $email->encode ();
$final ['headers'] = array_merge ( $final ['headers'], $hdrs );
$smtp = Mail::factory ( 'smtp', array (
'debug' => true,
'host' => $host,
'auth' => true,
'port' => $port,
'username' => $username,
'password' => $password
) );
$mail = $smtp->send ( $to_address, $final ['headers'], $final ['body'] );
此示例在运行xampp的localhost上运行良好。但是一旦我尝试让它在服务器上工作,我就会收到带有附件的邮件:
not supported calender message.ics
这是在Outlook 2010中。我可以双击该文件,它会显示正确的日历文件。我错过了什么?
在带有Exchange 2010服务器的Windows 7上运行。
使用Pear Mail 1.2.0和PHP