我想向用戶發送icalendar,以便他們可以在Outlook中打開這些ics文件並保存約會。我使用的郵件是'phpmailer.php'。icalendar和phpmailer.php
問題是它在郵件正文中發送html格式的html。這裏是我的代碼
$text="
BEGIN:VCALENDAR
VERSION:1.0
BEGIN:VEVENT
CATEGORIES:MEETING
STATUS:TENTATIVE
DTSTART:".$startDateTime."
DTEND:".$endDateTime."
SUMMARY:Interview for the candidate".$cname."
DESCRIPTION:".$message."
CLASS:PRIVATE
END:VEVENT
END:VCALENDAR";
$mail->SetFrom('[email protected]', 'xxxx');
$mail->IsSMTP();
$mail->Host = "smtp.mail.yahoo.com";
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'xxxxx';
$mail->AddAddress($addresses[$i]);
$mail->Subject = "Interview schedule of Candidate";
$headers = "From: Sender\n";
$headers .= "Reply-To: [email protected]\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/calendar; method=REQUEST; charset=utf-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Content-class: urn:content-classes:calendarmessage\n";
$mail->Body=$body;
if(!$mail->Send($headers,$body))
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message sent!";
}
請讓我知道我的代碼有什麼問題。 在此先感謝
你爲什麼不把它作爲附件發送? – Nelson
謝謝@納爾遜,我用附件:) –
@Nelson你有什麼想法,我怎麼能實現與zend_mail相同。 [鏈接](http://stackoverflow.com/questions/17646307/sending-ical-through-zend-mail) –