第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何為swift mailer php傳遞多個(gè)標(biāo)頭

如何為swift mailer php傳遞多個(gè)標(biāo)頭

PHP
喵喵時(shí)光機(jī) 2022-01-02 17:21:39
我正在使用 php 在 Outlook 中創(chuàng)建會(huì)議,我發(fā)現(xiàn)了幾個(gè)例子并嘗試實(shí)現(xiàn)它的工作,但它正在使用php mail() method,在 php 郵件方法中我知道如何傳遞標(biāo)題,但我想要實(shí)現(xiàn)的項(xiàng)目正在使用 swift mailer 和我不知道如何在 swift mailer 中定義這些標(biāo)題,以下是一個(gè)使用 php mail() 的工作示例$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 = "ABCD EFGH";$domain = 'mydomain.com';//Create Email Headers$mime_boundary = "----Meeting Booking----".MD5(TIME());$headers = "From: ".$from_name." <".$from_address.">\n";$headers .= "Reply-To: ".$from_name." <".$from_address.">\n";$headers .= "MIME-Version: 1.0\n";$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";$headers .= "Content-class: urn:content-classes:calendarmessage\n";//Create Email Body (HTML)$message = "--$mime_boundary\r\n";$message .= "Content-Type: text/html; charset=UTF-8\n";$message .= "Content-Transfer-Encoding: 8bit\n\n";$message .= "<html>\n";$message .= "<body>\n";$message .= '<p>Dear '.$to_name.',</p>';$message .= '<p>'.$description.'</p>';$message .= "</body>\n";$message .= "</html>\n";$message .= "--$mime_boundary\r\n";$ical = 'BEGIN:VCALENDAR' . "\r\n" .'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "\r\n" .'VERSION:2.0' . "\r\n" .'METHOD:REQUEST' . "\r\n" .'BEGIN:VTIMEZONE' . "\r\n" .'TZID:Eastern Time' . "\r\n" .'BEGIN:STANDARD' . "\r\n" .'DTSTART:20091101T020000' . "\r\n" .'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11' . "\r\n" .'TZOFFSETFROM:-0400' . "\r\n" .'TZOFFSETTO:-0500' . "\r\n" .'TZNAME:EST' . "\r\n" .'END:STANDARD' . "\r\n" .'BEGIN:DAYLIGHT' . "\r\n" .但我想在 swift mailer 中使用這個(gè)我不知道如何為 swift mailer 創(chuàng)建標(biāo)題以及如何在 swift 撰寫(xiě)電子郵件時(shí)通過(guò)任何人可以幫助我想要這個(gè)。
查看完整描述

1 回答

?
慕的地8271018

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();


查看完整回答
反對(duì) 回復(fù) 2022-01-02
  • 1 回答
  • 0 關(guān)注
  • 141 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)