icalendar and phpmailer.php

偶尔善良 提交于 2020-01-24 18:20:07

问题


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


回答1:


You could also have tried:

$mail->IsHTML(FALSE);



回答2:


The following solution worked for me:

$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



回答3:


This solution Works for me. without attachemnt

$mail->AddStringAttachment("my_content_here", "meeting.ics", "7bit", "text/calendar; charset=utf-8; method=REQUEST");


来源:https://stackoverflow.com/questions/12726735/icalendar-and-phpmailer-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!