When i send mail from laravel to gmail, outlook or zoho workplace, it working fine and receive email on all three plateform but RSVP only show in Google Gmail, not in zoho and outlook. Below is my code with ical file output. Code for sending Mail
$cal = Calendar::create('Laracon online')
->productIdentifier('Kutac.cz')
->withoutTimezone()
->event(Event::create('Event Testing')
->uniqueIdentifier(rand(4,9999))
->startsAt(new DateTime('30 March 2024 15:00'))
->endsAt(new DateTime('30 March 2024 16:00'))
->organizer('[email protected]', 'Vyacare')
->attendee('[email protected]', null,ParticipationStatus::needs_action(),true)
->alertMinutesBefore(10, 'Notify Before 10 minutes')
->description("Here goes description")
->address('Online - Google Meet')
->url("https://google.com")// Add LOCATION property
);
$cal->appendProperty(TextProperty::create('CLASS', 'PUBLIC'));
$cal->appendProperty(TextProperty::create('METHOD', 'REQUEST'));
$cal = $cal->get();
$meetingEmail = new MeetingScheduleEmail($office, $emailSubject, $messageBody, $cal);
SendLuxSciEmail::dispatch($recipientEmail, $meetingEmail,$cal,'event.ics');
My MeetingScheduleEmail file
public function __construct($office,$emailSubject,$messageBody,$cal)
{
$this->cal = $cal;
$this->fromName = $office->name;
$this->subject = $emailSubject;
$this->to = '[email protected]';
$this->attachData($cal,'event.ics', [
'mime' => 'text/calendar; charset=UTF-8; method=REQUEST',
]);
$this->body = $this->view('emails.patient', ['emailBody' => $messageBody,'participants' => $this->participants])->render();
}
My SendLux file code
class SendLuxSciEmail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $toAddress;
protected $mailable;
private $icsContent;
private $fileName;
public function __construct($toAddress, $mailable ,$icsContent = null, $fileName = null)
{
$this->toAddress = $toAddress;
$this->mailable = $mailable;
$this->icsContent = $icsContent;
$this->fileName = $fileName;
}
public function handle()
{
Sender::sendEmail($this->toAddress, $this->mailable, $this->icsContent, $this->fileName);
}
}
sendEmail function
public static function sendEmail($to, $mailable, $file = null, $fileName = null)
{
$client = new Client;
$sendEmailOrTextRequest = new SendEmailOrTextRequest();
$sendEmailOrTextRequest->from_name = $mailable->fromName;
$sendEmailOrTextRequest->attachments = $mailable->rawAttachments;
$sendEmailOrTextRequest->from_address = "[email protected]";
$sendEmailOrTextRequest->to = [$to];
$sendEmailOrTextRequest->subject = $mailable->subject;
$sendEmailOrTextRequest->body_type = BodyType::Html;
$sendEmailOrTextRequest->body = $mailable->body;
$client->sendEmailOrText($sendEmailOrTextRequest, $file, $fileName);
}
my body code
function sendEmailOrText(SendEmailOrTextRequest $request, $file, $fileName){
$hash = hash('sha256', $file);
$attachment = (object) ['hash' => $hash, 'name' => $fileName];
$request->attachments = array($attachment); // assign the attachment to request
$method="POST";
$path ="/perl/api/v2/user/" . $this->_params['user'] . "/email/compose/secureline/send";
$auth = $authToken;
$Arraycontents = json_encode($request);
$eol = "\r\n"; //default line-break for mime type
$BOUNDARY = md5(time()); //random boundaryid, is a separator for each param on my post curl function
$BODY=""; //init my curl body
$BODY.= '--'.$BOUNDARY. $eol; //start param header
$BODY.= 'Content-Type: application/json' . $eol; //set the json part of the request
// set the luxsci standards for sending the JSON. last Content with 2 $eol, in this case is only 1 content.
$BODY .= 'Content-Disposition: form-data; name="json"; filename="json.js"' . $eol . $eol;
$BODY .= $Arraycontents . $eol;//param data in this case is a simple post data and 1 $eol for the end of the data
$BODY.= '--'.$BOUNDARY. $eol; // start 2nd param,
$BODY.= 'Content-Disposition: form-data; name="files"; filename="'.$fileName.'"'. $eol; //Content data for post file
$BODY.= 'Content-Type: application/octet-stream' . $eol. $eol; //content type
$BODY.= $file . $eol; // set the data of the file within boundary
$BODY.= '--'.$BOUNDARY .'--' . $eol. $eol; // we close the boundary header.
//further code }
My .ical file format which is $BODY
BEGIN:VCALENDAR
VERSION:2.0
PRODID:Kutac.cz
NAME:Laracon online
X-WR-CALNAME:Laracon online
CLASS:PUBLIC
METHOD:REQUEST
BEGIN:VEVENT
UID:9401
DTSTAMP:20240328T071205Z
SUMMARY:Event Testing
DESCRIPTION:Here goes description
LOCATION:Online - Google Meet
ORGANIZER;CN=Vyacare:MAILTO:[email protected]
ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION:MAILTO:[email protected]
URL:https://google.com
DTSTART:20240330T150000
DTEND:20240330T160000
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:Notify Before 10 minutes
TRIGGER:-PT10M
END:VALARM
END:VEVENT
END:VCALENDAR