Create invite meeting with php mail()

Questions, comments, and problems with Zimbra on Apple desktops & general CalDAV / CardDAV questions.
Anthony
Posts: 1
Joined: Thu Feb 15, 2018 10:16 am

Create invite meeting with php mail()

Postby Anthony » Thu Feb 15, 2018 12:06 pm

Hello,

I would like to send an invitation to a meeting in php.

I managed to create a .ics file that can be integrated into Zimbra, but I do not know how to create the invitation as it can be done in Zimbra.

Code: Select all

<?php

$from_name = "webmaster";       
$from_address = "webmaster@example.com";       
$to_name = "Anthony";       
$to_address = "antho@test.com";       
$startTime = "15/02/2018 18:00:00";       
$endTime = "15/02/2018 19:00:00";       
$subject = "My Test Subject";       
$description = "My Awesome Description";       
$location = "Joe's House";
sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location);


function sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location)
{
    $domain = 'exchangecore.com';

    //Create Email Headers
    $mime_boundary = "----Meeting Booking----".MD5(TIME());

    $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\r\n";
    $message .= "Content-Type: text/html; charset=UTF-8\n";
    $message .= "Content-Transfer-Encoding: quoted-printable\n\n";
    $message .= "<html>\n";
    $message .= "<body>\n";
    $message .= '<p>Dear '.$to_name.',</p>';
    $message .= '<p>'.$description.'</p>';
    $message .= "</body>\n";
    $message .= "</html>\n";
    $message .= "--$mime_boundary\r\n";

    $ical = 'BEGIN:VCALENDAR' . "\r\n" .
    'PRODID:Zimbra-Calendar-Provider' . "\r\n" .
    'VERSION:2.0' . "\r\n" .
    'METHOD:PUBLISH' . "\r\n" .
    'BEGIN:VTIMEZONE' . "\r\n" .
    'TZID:Europe//Berlin' . "\r\n" .
    'BEGIN:STANDARD' . "\r\n" .
    'DTSTART:16010101T030000' . "\r\n" .
    'TZOFFSETTO:+0200' . "\r\n" .
    'TZOFFSETFROM:+0100' . "\r\n" .
    'RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=-1SU' . "\r\n" .
    'TZNAME:CEST' . "\r\n" .
    'END:STANDARD' . "\r\n" .
    'BEGIN:DAYLIGHT' . "\r\n" .
    'DTSTART:16010101T020000' . "\r\n" .
    'TZOFFSETTO:+0200' . "\r\n" .
    'TZOFFSETFROM:+0100' . "\r\n" .
    'RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=-1SU' . "\r\n" .
    'TZNAME:CEST' . "\r\n" .
    'END:DAYLIGHT' . "\r\n" .
    'END:VTIMEZONE' . "\r\n" .   
    'BEGIN:VEVENT' . "\r\n" .
   'UID:'.date("Ymd\TGis", strtotime($startTime)).rand()."@".$domain."\r\n" .
    'SUMMARY:' . $subject . "\r\n" .
    'LOCATION:' . $location . "\r\n" .
    'ATTENDEE;CN="'.$to_name.'";ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:MAILTO:'.$to_address. "\r\n" .
    'ORGANIZER;CN="'.$from_name.'":MAILTO:'.$from_address. "\r\n" .
    'DTSTART;TZID="Europe/Berlin":20180215T210000' . "\r\n" .
    'DTEND;TZID="Europe/Berlin":20180215T213000' . "\r\n" .
    'STATUS:CONFIRMED'. "\r\n" .
    'CLASS:PUBLIC'. "\r\n" .
    'TRANSP:OPAQUE'. "\r\n" .
    'LAST-MODIFIED:' . date("Ymd\TGis") . "\r\n" .
    'DTSTAMP:'.date("Ymd\TGis"). "\r\n" .
    'SEQUENCE:1'. "\r\n" .
    'BEGIN:VALARM' . "\r\n" .
    'TRIGGER;RELATED=START:-PT5M' . "\r\n" .
    'DESCRIPTION:Reminder' . "\r\n" .
    'END:VALARM' . "\r\n" .
    'END:VEVENT'. "\r\n" .
    'END:VCALENDAR'. "\r\n";

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

    $mailsent = mail($to_address, $subject, $message, $headers);

    return ($mailsent)?(true):(false);
}

?>



Thanks in advance,

Regards,


Return to “CalDAV / CardDAV / iSync”

Who is online

Users browsing this forum: No registered users and 1 guest