gpt4 book ai didi

php - icalendar 和 phpmailer.php

转载 作者:行者123 更新时间:2023-12-04 15:52:28 26 4
gpt4 key购买 nike

我正在尝试将 icalendar 发送给用户,以便他们可以在 outlook 中打开这些 ics 文件并保存约会。我使用的邮件程序是“phpmailer.php”。

问题是它在消息正文中将 ical 格式作为 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('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->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

关于php - icalendar 和 phpmailer.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12726735/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com