【问题标题】:How to make a email calendar invite automatically accepted (php)?如何使电子邮件日历邀请自动接受(php)?
【发布时间】:2016-01-18 23:10:14
【问题描述】:

我正在通过电子邮件发送日历邀请,但我希望它自动被接受。

我的代码有什么可以改变的吗?我的代码如下所示:

function sendIcalEmail ($firstname, $lastname, $email, $meeting_date, $meeting_name, $meeting_duration)  {
    $from_name = “My Name”;
    $from_address = “myname@mydomain.com”;
    $subject = “Meeting Booking”; //Doubles as email subject and meeting subject in calendar
    $meeting_description = “Here is a brief description of my meeting\n\n”;
    $meeting_location = “My Office”; //Where will your meeting take place

    //Convert MYSQL datetime and construct iCal start, end and issue dates
    $meetingstamp = strtotime($meeting_date . ” UTC”);
    $dtstart= gmdate(”Ymd\THis\Z”,$meetingstamp);
    $dtend= gmdate(”Ymd\THis\Z”,$meetingstamp+$meeting_duration);
    $todaystamp = gmdate(”Ymd\THis\Z”);

    //Create unique identifier
    $cal_uid = date(’Ymd’).’T’.date(’His’).”-”.rand().”@mydomain.com”;

    //Create Mime Boundry
    $mime_boundary = “—-Meeting Booking—-”.md5(time());

    //Create Email Headers
    $headers = “From: “.$from_name.” <”.$from_address.”>\n”;
    $headers .= “Reply-To: “.$from_name.” <”.$from_address.”>\n”;

    $headers .= “MIME-Version: 1.0\n”;
    $headers .= “Content-Type: multipart/alternative; boundary=\”$mime_boundary\”\n”;
    $headers .= “Content-class: urn:content-classes:calendarmessage\n”;

    //Create Email Body (HTML)
    $message .= “–$mime_boundary\n”;
    $message .= “Content-Type: text/html; charset=UTF-8\n”;
    $message .= “Content-Transfer-Encoding: 8bit\n\n”;

    $message .= “<html>\n”;
    $message .= “<body>\n”;
    $message .= ‘<p>Dear ‘.$firstname.’ ‘.$lastname.’,</p>’;
    $message .= ‘<p>Here is my HTML Email / Used for Meeting Description</p>’;
    $message .= “</body>\n”;
    $message .= “</html>\n”;
    $message .= “–$mime_boundary\n”;

    //Create ICAL Content (Google rfc 2445 for details and examples of usage, beware of adding tabs)
    $ical =    ‘BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
ORGANIZER:MAILTO:’.$from_address.’
DTSTART:’.$dtstart.’
DTEND:’.$dtend.’
LOCATION:’.$meeting_location.’
TRANSP:OPAQUE
SEQUENCE:0
UID:’.$cal_uid.’
DTSTAMP:’.$todaystamp.’
DESCRIPTION:’.$meeting_description.’
SUMMARY:’.$subject.’
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR’;

    $message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST;charset=utf-8\n';
    $message .= 'Content-Transfer-Encoding: 8bit\n\n';
    $message .= $ical;

    //SEND MAIL
    $mail_sent = @mail( $email, $subject, $message, $headers );

    if($mail_sent)     {
        return true;
    } else {
        return false;
    }

}

【问题讨论】:

    标签: icalendar


    【解决方案1】:

    恕我直言,不可能或不应该发布自动接受的邀请。相反,您应该通知您的用户,他们可以更改 Outlook 中的设置以自动接受(某些)邀请。 顺便说一句,感谢您的 sn-p。正是我需要的。

    【讨论】:

      【解决方案2】:

      您好,对于日历自动接受,您应该在代码中添加给定的行以创建 ics 文件。 ATTENDEE;PARTSTAT=ACCEPTED;CN= ExampleName1 c;EMAIL=example1@mail.com:MAILTO:example1@mail.com

      ATTENDEE;PARTSTAT=ACCEPTED;CN= ExampleName2 c;EMAIL=example2@mail.comMAILTO:example2@mail.com

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-09-02
        • 2015-08-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-11-18
        • 1970-01-01
        • 2021-08-08
        相关资源
        最近更新 更多