src/Utility/ICal/IcEmail.php
public function sendCalendarEmail(string $to, string $subject, string $content, array $eventOptions, string $config = 'default') : array
    {
        // Get iCal calendar
        $calendar = $this->getEventCalendar($eventOptions);

        // FIXME: WTF happened to new lines???
        $headers = "Content-Type: text/calendar; charset=utf-8";
        $headers .= 'Content-Disposition: attachment; filename="event.ics"';

        $emailer = new Email($config);
        $emailer->setTo($to)
            ->setHeaders([$headers])
            ->setSubject($subject)
            ->addAttachments(['event.ics' => [
                'contentDisposition' => true,
                'mimetype' => 'text/calendar',
                'data' => $calendar->render()
            ]]);

        return $emailer->send($content);
    }
public function sendCalendarEmail(string $to, string $subject, string $content, array $eventOptions, string $config = 'default') : array
    {
        // Get iCal calendar
        $calendar = $this->getEventCalendar($eventOptions);

        // FIXME: WTF happened to new lines???
        $headers = "Content-Type: text/calendar; charset=utf-8";
        $headers .= 'Content-Disposition: attachment; filename="event.ics"';

        $emailer = new Email($config);
        $emailer->setTo($to)
            ->setHeaders([$headers])
            ->setSubject($subject)
            ->addAttachments(['event.ics' => [
                'contentDisposition' => true,
                'mimetype' => 'text/calendar',
                'data' => $calendar->render()
            ]]);

        return $emailer->send($content);
    }
public function sendCalendarEmail ( string $ to , string $ subject , string $ content , array $ eventOptions , string $ config = 'default' ) : array { // Get iCal calendar $ calendar = $ this -> getEventCalendar ( $ eventOptions ) ; // FIXME: WTF happened to new lines??? $ headers = "Content-Type: text/calendar; charset=utf-8" ; $ headers .= 'Content-Disposition: attachment; filename="event.ics"' ; $ emailer = new Email ( $ config ) ; $ emailer -> setTo ( $ to ) -> setHeaders ( [ $ headers ] ) -> setSubject ( $ subject ) -> addAttachments ( [ 'event.ics' => [ 'contentDisposition' => true , 'mimetype' => 'text/calendar' , 'data' => $ calendar -> render ( ) ] ] ) ; return $ emailer -> send ( $ content ) ; }
Send email with calendar attachment

@param string $to Destination email address
@param string $subject Email subject
@param string $content Email message content
@param mixed[] $eventOptions Event options for calendar attachment
@param string $config Email config to use ('default' if omitted)
@return mixed[] Result of \Cake\Mailer\Email::send()
Send email with calendar attachment