【发布时间】:2021-07-26 10:05:42
【问题描述】:
我正在尝试使用 laravel 8 以发送普通会议邀请的标准方式将 .ics 文件发送到 Outlook。我尝试过复制确切的邀请和许多不同的方法,但这里似乎没有任何效果。我相信这与我发送的方式与发送的内容有关。我想使用 Laravel 邮件 API。我在下面提供了一些代码来说明我到目前为止所做的事情。我复制了一个在我的常规 Outlook 上工作的精确 .ics 以作为文件的基础,但仍然无法正常工作。
我将不胜感激。
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use App\Models\Meeting;
use App\Models\User;
use Carbon\Carbon;
class MeetingInviteMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Build the message.
*
* @return $this
*/
public function build(){
$from_name = "Company Name";
$from_address = "info@example.com";
$to_name = "Receiver Name";
$to_address = "name@example.com";
$startTime = $start->format("m/d/Y H:i:s"); //these are carbon datetimes
$endTime = $end->format("m/d/Y H:i:s");
$subject = "Meeting Subject";
$location = "Zoom Dial-in TBD";
$domain = 'example.com';
$ical = 'BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 16.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VTIMEZONE
TZID:America/New_York
BEGIN:STANDARD
DTSTART:16011104T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010311T020000
RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20210504T000631Z
DESCRIPTION: XXXXX
DTEND;TZID=America/New_York:20210503T210000
DTSTAMP:20210504T000611Z
DTSTART;TZID=America/New_York:20210503T200000
LAST-MODIFIED:20210504T000631Z
LOCATION:https://zoom.us/j/**************************
PRIORITY:5
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:My Meeting
TRANSP:OPAQUE
UID:20210504T000611Z-95378197685@fe80:0:0:0:1080:3fff:fe1c:150dens5
X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E
N">\n<HTML>\n<HEAD>\n<META NAME="Generator" CONTENT="MS Exchange Server ve
rsion 16.0.13901.20436">\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n<!-- Converted
from text/plain format -->\n\n<P><FONT SIZE=2>Company is inviti
ng you to a scheduled Zoom meeting.</FONT>\n</P>\n\n<P><FONT SIZE=2>Join Z
oom Meeting</FONT>\n\n<BR><FONT SIZE=2><A HREF="https://zoom.us/j/*******">https://zoom.us/j/*******</A></FONT>\n</P>\n\n<P><FONT SIZE=2>Mee
ting ID: ******</FONT>\n\n<BR><FONT SIZE=2>Passcode: ******</FONT>\
n</P>\n\n</BODY>\n</HTML>
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-IMPORTANCE:1
END:VEVENT
END:VCALENDAR
';
return $this->from('info@example.com')
->markdown('emails.meeting-invite') //markdown is not significant, not even sure its needed but laravel requires it
->attachData($ical, 'invite.ics', [
'mime' => 'text/calendar;charset=UTF-8;method=REQUEST',
]);
}
}
【问题讨论】:
标签: php laravel email outlook google-calendar-api