HI @lprice try it in your Mail class.
return $this->view('emails.bla-bla')
->attach($link->ics(), ['as' => 'event.ics', 'mime' => 'text/calendar'])
->subject("Email subject");
I hope this proves useful
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Anyone has maybe some example code or pointers on how to attach an ICS file to an email so that email clients recognize it. I've tried, but neither outlook nor Gmail recognizes the email as an invite.
I'm making use of https://github.com/spatie/calendar-links
I have an action class "EventICSAction.php" which creates the ICS file:
$link = Link::create($event->name, $event->start_at, $event->end_at, $allDay = false)
->description(($event->body) ?? __('No Description'))
->address($event->location->name);
return $link->ics();
And then on the email notification, I attach it to the email. I've tried different mime types etc. all without success.:
public function toMail($notifiable)
{
return (new MailMessage)
->subject(__('Your participation was registered'))
->markdown('notifications.participant.created', ['user' => $this->user, 'booking' => $this->booking])
->attachData((new EventICSAction)->execute($this->booking->event), 'invite.ics', [
'Content-Type' => 'text/calendar; charset="utf-8"; method=REQUEST',
// 'mime' => 'text/calendar; charset="utf-8"; method=REQUEST',
'Content-Disposition' => 'attachment; filename="invite.ics"',
]);
}
Any ideas would be appreciated!
Thanks!
Please or to participate in this conversation.