简体   繁体   English

在 php mailer 中发送 i 日历作为邮件正文

[英]Sending an i calendar as mail body in php mailer

I am using php mailer to send mails to recipients and I need to send i calendar events, i know how to send them as an attachment but i want to send them in mail body.我正在使用 php mailer 向收件人发送邮件,我需要发送日历事件,我知道如何将它们作为附件发送,但我想在邮件正文中发送它们。 is it possible?是否可以?

$message = "You have been invited to the online meeting '".$schedule->schedule_name.
                                    "', On ".$date." (".$start_time."-".$end_time.") by Tuti.World \n
                                    (See attachments for more details)";

        $ical_content = "BEGIN:VCALENDAR
                                        VERSION:2.0
                                        PRODID://Drupal iCal API//EN
                                        BEGIN:VEVENT
                                        UID:http://www.icalmaker.com/event/d8fefcc9-a576-4432-8b20-40e90889affd
                                        DTSTAMP:".$date.
                                        "DTSTART:".$start_time.
                                        "DTEND:".$end_time.
                                        "SUMMARY:Online Meeting
                                        END:VEVENT
                                        END:VCALENDAR";



$mail->msgHTML($message);
$mail->addStringAttachment($ical_content,$file,'base64','text/calendar');
$mail->send();

these are the code blocks of the current mail body and calendar event...这些是当前邮件正文和日历事件的代码块...

PHPMailer has built-in iCal support, which it uses to create a third text/calendar part within a multipart/alternative structure. PHPMailer 具有内置的 iCal 支持,它用于在multipart/alternative结构中创建第三个text/calendar部分。 This is "the RFC way", but unfortunately iCal clients are a total mess, and nothing works consistently across Outlook, Gmail, and Apple Mail.这是“RFC 方式”,但不幸的是,iCal 客户端一团糟,在 Outlook、Gmail 和 Apple Mail 中没有任何东西能始终如一地工作。 The best approach is to go with the standard structure, but also add the same data as an attachment (like you're already doing).最好的方法是使用标准结构,但也添加相同的数据作为附件(就像您已经在做的那样)。 The only change you need to make in your code is to add this line:您需要在代码中进行的唯一更改是添加以下行:

$mail->Ical = $ical_content;

You also need to be very careful with your iCal content - Outlook is particularly picky, and the tiniest thing wrong will result in it not working at all, so I recommend testing using an iCal string generated by Outlook to start with, so that you isolate your iCal sending from any other issues you have relating to what's in it.你还需要非常小心你的 iCal 内容——Outlook 特别挑剔,最微小的错误都会导致它根本无法工作,所以我建议使用 Outlook生成的 iCal 字符串开始测试,这样你就可以隔离您的 iCal 发送的任何其他与其中内容相关的问题。

I have been using phpmailer for years for events and it has always worked.我多年来一直在使用 phpmailer 进行活动,它一直有效。 I always have problems only with apple.我总是只有苹果有问题。 With IOS 13 I had to wait 4 months for them to fix it.使用 IOS 13 我不得不等待 4 个月他们才能修复它。 Now with 14.4 the same problem, the yes/no/maybe buttons don't come out anymore so if I insert the event from iphone it doesn't synchronize it with outlook.现在使用 14.4 同样的问题,yes/no/maybe 按钮不再出现,所以如果我从 iphone 插入事件,它不会与 Outlook 同步。 Vice versa it works.反之亦然。 If I accept it from iphone, I update the event and when I accept it from outlook automatically finds on the iphone what was an isolated event and updates it, I assume because the id is unique anyway.如果我从 iphone 接受它,我会更新事件,当我从 Outlook 接受它时,会自动在 iphone 上找到什么是孤立事件并更新它,我假设因为 id 无论如何都是唯一的。 It's frunstrante apple side that continues to make mistakes.继续犯错误的是令人沮丧的苹果方面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM