1 回答

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超4個(gè)贊
您正在使用 swiftmailer 以避免需要自己設(shè)置標(biāo)題。您可以發(fā)送帶有您需要的標(biāo)題的郵件,如下所示:
$from_name = "Some One";
$from_address = "def@abc.com";
$to_name = "Soem Two";
$to_address = "xyz@abc.com";
$date = '20190905';
$startTime = '13:20:00';
$endTime = '19:00:00';
$subject = "Standup Meeting";
$description = "The purpose of the meeting is to discuss works done and inprogress";
$location = "acfr ffs";
$domain = 'my.com';
/**
* @var \yii\swiftmailer\Message $mail
*/
$mail=Yii::$app->mailer->compose()
->setFrom([$from_address => $from_name])
->setReplyTo([$from_address => $from_name])
->setSubject($subject)
->setTo([$to_address => $to_name]);
$mail->addHeader('Content-class', 'urn:content-classes:calendarmessage');
//Create Email Body (HTML)
$message = "<html>\n";
$message .= "<body>\n";
$message .= '<p>Dear '.$to_name.',</p>';
$message .= '<p>'.$description.'</p>';
$message .= "</body>\n";
$message .= "</html>\n";
$ical = 'BEGIN:VCALENDAR' . "\r\n" .
... skipped the body for better readability ...
'END:VCALENDAR'. "\r\n";
$swiftMail = $mail->getSwiftMessage();
$swiftMail->setContentType('multipart/alternative');
$swiftMail->addPart($message, 'text/html');
$swiftMail->addPart(
$ical,
'text/calendar;name="meeting.ics";method=REQUEST',
null
);
$mail->send();
如果您不需要這個(gè)特定的標(biāo)題并且您的目標(biāo)只是發(fā)送日歷事件,您可以讓它變得更加簡(jiǎn)單
$from_name = "Some One";
$from_address = "def@abc.com";
$to_name = "Soem Two";
$to_address = "xyz@abc.com";
$date = '20190905';
$startTime = '13:20:00';
$endTime = '19:00:00';
$subject = "Standup Meeting";
$description = "The purpose of the meeting is to discuss works done and inprogress";
$location = "cfrt hjd";
$domain = 'my.com';
$mail=Yii::$app->mailer->compose()
->setFrom([$from_address => $from_name])
->setReplyTo([$from_address => $from_name])
->setSubject($subject)
->setTo([$to_address => $to_name]);
//Create Email Body (HTML)
$message = "<html>\n";
$message .= "<body>\n";
$message .= '<p>Dear '.$to_name.',</p>';
$message .= '<p>'.$description.'</p>';
$message .= "</body>\n";
$message .= "</html>\n";
$ical = 'BEGIN:VCALENDAR' . "\r\n" .
... skipped the body for better readability ...
'END:VCALENDAR'. "\r\n";
$mail->setHtmlBody($message);
$mail->attachContent(
$ical,
[
'contentType' => 'text/calendar;name="meeting.ics";method=REQUEST'
]
);
$mail->send();
- 1 回答
- 0 關(guān)注
- 141 瀏覽
添加回答
舉報(bào)