本文介绍了icalendar和phpmailer.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将icalendar发送给用户,以便他们可以在Outlook中打开这些ics文件并保存约会.我正在使用的mailer是'phpmailer.php'.问题是它在邮件正文中以html格式发送ical格式.这是我的代码
$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);
i am trying to send icalendar to the users, so that they can open these ics files in outlook and save the appointment. mailer i am using is 'phpmailer.php'.
problem is that it sends ical format as html in message body. Here is my code
$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!";
}
Please let me know what is wrong with my code.Thanks in advance
解决方案
You could also have tried:
$mail->IsHTML(FALSE);
这篇关于icalendar和phpmailer.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!