Authentication Bypass in MailboxImportServlet vulnerability (reminder)
https://blog.zimbra.com/2022/08/authentication-bypass-in-mailboximportservlet-vulnerability/

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,


bulletxt
Advanced member
Advanced member
Posts: 54
Joined: Sat Sep 13, 2014 1:08 am

Re: Create invite meeting with php mail()

Postby bulletxt » Fri Dec 28, 2018 10:49 pm

Please use PHP Mailer instead of native php mail function.

Follow simple instructions here: https://blog.webnersolutions.com/how-to ... -phpmailer

If you have issues let me know
memon.salman
Posts: 1
Joined: Tue May 18, 2021 10:25 am

Re: Create invite meeting with php mail()

Postby memon.salman » Tue May 18, 2021 10:30 am

Hi Bulltxt,
I am trying to achieve the same sending invite function php mailer using smtp but i am having a lot more troubles. Do you have any simple code of a page i use.


Code: Select all

<?php
session_start();
include("../ot-config/config.php");

// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

// Load Composer's autoloader
require 'vendor/autoload.php';

// Instantiation and passing `true` enables exceptions

try {

      $Email = "memon.salman@gmail.com";

      //Be very careful with this string. You may need to add CLRF (\r\n) line breaks depending on how your server handles line endings.
      /*$ical_content = 'BEGIN:VCALENDAR
      PRODID:-//Mailer//NONSGML v1.0//EN
      VERSION:2.0
      CALSCALE:GREGORIAN
      METHOD:REQUEST
      BEGIN:VEVENT
      DTSTART:'.$date.'T'.$startTime.'00Z
      DTEND:'.$date.'T'.$endTime.'00Z
      DTSTAMP:' . gmdate('Ymd').'T'. gmdate('His') . 'Z
      ORGANIZER;CN="'.$organizer.'":mailto:'.$organizer_email.'
      UID:' . md5(uniqid(mt_rand(), true)) . '@example.com
      ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN="'.$participant_name_1.'";X-NUM-GUESTS=0:mailto:'.$participant_email_1.'
      ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN="'.$participant_name_2.'";X-NUM-GUESTS=0:mailto:'.$participant_email_2.'
      CREATED:' . gmdate('Ymd').'T'. gmdate('His') . 'Z
      DESCRIPTION:'.$desc.'
      LAST-MODIFIED:' . gmdate('Ymd').'T'. gmdate('His') . 'Z
      SUMMARY:'.$subject.'
      LOCATION:'.$location.'
      END:VEVENT
      END:VCALENDAR';*/
      $ical_content = 'BEGIN:VCALENDAR
      RODID:-//Mailer//NONSGML v1.0//EN
      VERSION:2.0
      CALSCALE:GREGORIAN
      METHOD:REQUEST
      UID:http://www.icalmaker.com/event/d8fefcc9-a576-4432-8b20-40e90889affd
      DTSTAMP:20170203T045941Z
      DTSTART:20170214T060000Z
      DTEND:20170214T100000Z
      SUMMARY:Party in Daawat
      LOCATION:Hotel Daawat, Ground Floor, Phase 5, Sector 59, Near Post Office, Mohali 160059.
      DESCRIPTION:Dinner
      END:VEVENT
      END:VCALENDAR';
   
      $mail = new PHPMailer(true);
      $mail->isSMTP();
      $mail->Host = 'smtp.hostinger.com';
      $mail->Port = 587;                               
      $mail->SMTPAuth = true;
      $mail->CharSet = 'UTF-8';
      $mail->Username   = 'support@saflec.exhibitv.live';                     // SMTP username
      $mail->Password   = 'A5^(5*(q9v~ti';
      $mail->setFrom('support@saflec.exhibitv.live', ''.SITE_NAME.'');
      $mail->addAddress($Email);

      // Content
      $mail->isHTML(true);                                  // Set email format to HTML
      $mail->Subject = ''.SITE_NAME.' Meeting Email';
      $mail->ContentType = 'text/calendar';
      $mail->Body = 'Testing testing 321';
      $mail->AltBody = $ical_content;
      $mail->Ical = $ical_content;
      $mail->addStringAttachment($ical_content, 'ical.ics', 'base64', 'application/ics; name="ical.ics"'); //This seems to be important for Gmail


      //Send
      $mail->send();
      //if(!empty($ical_content)){
         //$mail->addStringAttachment($ical_content,'ical.ics','base64','text/calendar');
      /*}
      else {
         echo "error";
      }*/
      
}
catch(PDOException $error) 
{
   $message = $error->getMessage(); 
}

Return to “CalDAV / CardDAV / iSync”

Who is online

Users browsing this forum: No registered users and 2 guests