icalendar和phpmailer.php
我正在尝试将icalendar发送给用户,以便他们可以在outlook中打开这些ics文件并保存约会。我使用的mailer是“phpmailer.php” 问题是它在消息体中以html的形式发送ical格式。这是我的密码icalendar和phpmailer.php,php,phpmailer,icalendar,Php,Phpmailer,Icalendar,我正在尝试将icalendar发送给用户,以便他们可以在outlook中打开这些ics文件并保存约会。我使用的mailer是“phpmailer.php” 问题是它在消息体中以html的形式发送ical格式。这是我的密码 $text=" BEGIN:VCALENDAR VERSION:1.0 BEGIN:VEVENT CATEGORIES:MEETING STATUS:TENTATIVE DTSTART:".$startDateTime." DTEND:".$endDateTime." SUM
$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('xxxxxx@yahoo.com', 'xxxx');
$mail->IsSMTP();
$mail->Host = "smtp.mail.yahoo.com";
$mail->SMTPAuth = true;
$mail->Username = 'xxxxxxxx@yahoo.com';
$mail->Password = 'xxxxx';
$mail->AddAddress($addresses[$i]);
$mail->Subject = "Interview schedule of Candidate";
$headers = "From: Sender\n";
$headers .= "Reply-To: xxxxxx@yahoo.com\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!";
}
请让我知道我的代码有什么问题。
提前感谢您也可以尝试:
$mail->IsHTML(FALSE);
以下解决方案对我有效:
$mail->Subject = $name;
$mail->Body = $description;
$mail->AltBody = $body; // in your case once more the $text string
$mail->Ical = $message; // ical format, in your case $text string
这个解决方案对我有效。无附件
$mail->AddStringAttachment("my_content_here", "meeting.ics", "7bit", "text/calendar; charset=utf-8; method=REQUEST");
你为什么不把它作为附件发送呢?谢谢@Nelson我是用附件发送的:)@Nelson你知道我怎样才能用zend_mail实现同样的效果吗。我看不出您在哪里使用变量$text…您使用的是哪个版本的phpMailer?因为在5.2.6+中,send方法不接受任何参数。