Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为swift mailer php传递多个标题_Php_Email_Yii2_Swiftmailer - Fatal编程技术网

如何为swift mailer php传递多个标题

如何为swift mailer php传递多个标题,php,email,yii2,swiftmailer,Php,Email,Yii2,Swiftmailer,我正在使用php在outlook中创建会议,我发现了一些示例并尝试实现它,但它使用的是php mail()方法,在php mail方法中,我知道如何传递标题,但我要实现的项目使用的是swift mailer,我不知道如何在swift mailer中定义这些标题,下面是一个使用php mail()的工作示例 $from_name=“Some One”; $from_地址=”def@abc.com"; $to_name=“Soem-Two”; $to_地址=”xyz@abc.com"

我正在使用php在outlook中创建会议,我发现了一些示例并尝试实现它,但它使用的是
php mail()方法
,在php mail方法中,我知道如何传递标题,但我要实现的项目使用的是swift mailer,我不知道如何在swift mailer中定义这些标题,下面是一个使用php mail()的工作示例

$from_name=“Some One”;
$from_地址=”def@abc.com";        
$to_name=“Soem-Two”;
$to_地址=”xyz@abc.com";        
$date='20190905';
$startTime='13:20:00';
$endTime='19:00:00';
$subject=“站立会议”;
$description=“会议的目的是讨论已完成的工作和正在进行的工作”;
$location=“ABCD-EFGH”;
$domain='mydomain.com';
//创建电子邮件标题
$mime_boundary=“----会议预订----”.MD5(TIME());
$headers=“From:”.$From\u name.\n”;
$headers.=“回复:”.$from_name.“\n”;
$headers.=“MIME版本:1.0\n”;
$headers.=“内容类型:多部分/可选;边界=\”$mime\U边界\“\n”;
$headers.=“内容类:urn:Content类:calendarmessage\n”;
//创建电子邮件正文(HTML)
$message=“--$mime\U边界\r\n”;
$message.=“内容类型:text/html;字符集=UTF-8\n”;
$message.=“内容传输编码:8位\n\n”;
$message.=“\n”;
$message.=“\n”;
$message.='亲爱的'.$to_name',

'; $message.=''.$description.

'; $message.=“\n”; $message.=“\n”; $message.=“--$mime\u边界\r\n”; $ical='BEGIN:VCALENDAR'。“\r\n”。 'PRODID:-//微软公司//Outlook 10.0 MIMEDIR//EN'。“\r\n”。 '版本:2.0'。“\r\n”。 '方法:请求'。“\r\n”。 '开始:VTIMEZONE'。“\r\n”。 “TZID:东部时间”。“\r\n”。 “开始:标准”。“\r\n”。 “DTSTART:20091101T020000”。“\r\n”。 'RRULE:FREQ=每年;间隔=1;BYDAY=1SU;按月=11'。“\r\n”。 'TZOFFSETFROM:-0400'。“\r\n”。 “佐菲托:-0500”。“\r\n”。 'TZNAME:EST'。“\r\n”。 '结束:标准'。“\r\n”。 “开始:日光”。“\r\n”。 “DTSTART:20090301T020000”。“\r\n”。 'RRULE:FREQ=每年;间隔=1;BYDAY=2SU;按月=3'。“\r\n”。 'TZOFFSETFROM:-0500'。“\r\n”。 “佐菲托:-0400”。“\r\n”。 'TZNAME:EDST'。“\r\n”。 “结束:日光”。“\r\n”。 '结束:VTIMEZONE'。“\r\n”。 “开始:VEVENT”。“\r\n”。 "组织者,;CN=“.$from_name.”:MAILTO:“.$from_address。“\r\n”。 "与会者,;CN=“.$to_name.”;角色=REQ-参与者;RSVP=TRUE:MAILTO:'.$to_地址。“\r\n”。 “上次修改:”。日期(“Ymd\TGis”)。“\r\n”。 “UID:”.date(“Ymd\TGis”,strotime($startTime)).rand()。“@”。$domain.\r\n”。 “DTSTAMP:”.date(“Ymd\TGis”)。“\r\n”。 “DTSTART:”.$date。“T”。$startTime。“00Z\r\n”。 'DTEND:'.$date。“T”。$endTime。“00Z\r\n”。 “传输:不透明”。“\r\n”。 '顺序:1'。“\r\n”。 “摘要:”$主题。“\r\n”。 '位置:'$地点。“\r\n”。 “类别:公共”。“\r\n”。 “优先级:5”。“\r\n”。 “开始:瓦勒姆”。“\r\n”。 '触发器:-PT15M'。“\r\n”。 “操作:显示”。“\r\n”。 “说明:提醒”。“\r\n”。 "完:瓦尔阿姆"。“\r\n”。 “结束:VEVENT”。“\r\n”。 '结束:VCALENDAR'。“\r\n”; $message.='内容类型:文本/日历;name=“meeting.ics”;方法=请求“”。“\n”; $message.=“内容传输编码:8位\n\n”; $message.=$ical; $mailssent=mail($to_address,$subject,$message,$headers); 如果($mailssent) { 回音“发送会议电子邮件”; } 其他的 { 回音“发送电子邮件时出现问题”; }
但是我想在swift-mailer中使用它,我不知道如何为swift-mailer创建标题,也不知道在swift中编写电子邮件时如何传递。有人能帮忙吗 我想要这个

 $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 = "abcfer ";
        $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" .
        'DTSTART:20090301T020000' . "\r\n" .
        'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3' . "\r\n" .
        'TZOFFSETFROM:-0500' . "\r\n" .
        'TZOFFSETTO:-0400' . "\r\n" .
        'TZNAME:EDST' . "\r\n" .
        'END:DAYLIGHT' . "\r\n" .
        'END:VTIMEZONE' . "\r\n" .  
        'BEGIN:VEVENT' . "\r\n" .
        'ORGANIZER;CN="'.$from_name.'":MAILTO:'.$from_address. "\r\n" .
        'ATTENDEE;CN="'.$to_name.'";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:'.$to_address. "\r\n" .
        'LAST-MODIFIED:' . date("Ymd\TGis") . "\r\n" .
        'UID:'.date("Ymd\TGis", strtotime($startTime)).rand()."@".$domain."\r\n" .
        'DTSTAMP:'.date("Ymd\TGis"). "\r\n" .
        'DTSTART:'.$date."T".$startTime."00Z\r\n" .
        'DTEND:'.$date."T".$endTime."00Z\r\n" .
        'TRANSP:OPAQUE'. "\r\n" .
        'SEQUENCE:1'. "\r\n" .
        'SUMMARY:' . $subject . "\r\n" .
        'LOCATION:' . $location . "\r\n" .
        'CLASS:PUBLIC'. "\r\n" .
        'PRIORITY:5'. "\r\n" .
        'BEGIN:VALARM' . "\r\n" .
        'TRIGGER:-PT15M' . "\r\n" .
        'ACTION:DISPLAY' . "\r\n" .
        'DESCRIPTION:Reminder' . "\r\n" .
        'END:VALARM' . "\r\n" .
        'END:VEVENT'. "\r\n" .
        'END:VCALENDAR'. "\r\n";
        $message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST'."\n";
        $message .= "Content-Transfer-Encoding: 8bit\n\n";
        $message .= $ical;

         $message=Yii::$app->mailer->compose()
        ->setFrom($from_address)
        ->setTo($to_address)
        ->setSubject('This is subject') // ???? ??????
        ->addTextHeader($headers)
        ->setHtmlBody($message)
        ->send();
        var_dump($message);
$from_name=“Some One”;
$from_地址=”def@abc.com";        
$to_name=“Soem-Two”;
$to_地址=”xyz@abc.com";       
$date='20190905';
$startTime='13:20:00';
$endTime='19:00:00';
$subject=“站立会议”;
$description=“会议的目的是讨论已完成的工作和正在进行的工作”;
$location=“abcfer”;
$domain='mydomain.com';
//创建电子邮件标题
$mime_boundary=“----会议预订----”.MD5(TIME());
$headers=“From:”.$From\u name.\n”;
$headers.=“回复:”.$from_name.“\n”;
$headers.=“MIME版本:1.0\n”;
$headers.=“内容类型:多部分/可选;边界=\”$mime\U边界\“\n”;
$headers.=“内容类:urn:Content类:calendarmessage\n”;
//创建电子邮件正文(HTML)
$message=“--$mime\U边界\r\n”;
$message.=“内容类型:text/html;字符集=UTF-8\n”;
$message.=“内容传输编码:8位\n\n”;
$message.=“\n”;
$message.=“\n”;
$message.='亲爱的'.$to_name',

'; $message.=''.$description.

'; $message.=“\n”; $message.=“\n”; $message.=“--$mime\u边界\r\n”; $ical='BEGIN:VCALENDAR'。“\r\n”。 'PRODID:-//微软公司//Outlook 10.0 MIMEDIR//EN'。“\r\n”。 '版本:2.0'。“\r\n”。 '方法:请求'。“\r\n”。 '开始:VTIMEZONE'。“\r\n”。 “TZID:东部时间”。“\r\n”。 “开始:标准”。“\r\n”。 “DTSTART:20091101T020000”。“\r\n”。 'RRULE:FREQ=每年;间隔=1;BYDAY=1SU;按月=11'。“\r\n”。 'TZOFFSETFROM:-0400'。“\r\n”。 “佐菲托:-0500”。“\r\n”。 'TZNAME:EST'。“\r\n”。 '结束:标准'。“\r\n”。 “开始:日光”。“\r\n”。 “DTSTART:20090301T020000”。“\r\n”。 'RRULE:FREQ=每年;间隔=1;BYDAY=2SU;按月=3'。“\r\n”。 'TZOFFSETFROM:-0500'。“\r\n”。 “佐菲托:-0400”。“\r\n”。 'TZNAME:EDST'。“\r\n”。 “结束:日光”。“\r\n”。 '结束:VTIMEZONE'。“\r\n”。 “开始:VEVENT”。“\r\n”。 "组织者,;CN=“.$from_name.”:MAILTO:“.$from_address。“\r\n”。 "与会者,;CN=“.$to_name.”;角色=REQ-参与者;RSVP=T
 $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 = "abcfer ";
        $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" .
        'DTSTART:20090301T020000' . "\r\n" .
        'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3' . "\r\n" .
        'TZOFFSETFROM:-0500' . "\r\n" .
        'TZOFFSETTO:-0400' . "\r\n" .
        'TZNAME:EDST' . "\r\n" .
        'END:DAYLIGHT' . "\r\n" .
        'END:VTIMEZONE' . "\r\n" .  
        'BEGIN:VEVENT' . "\r\n" .
        'ORGANIZER;CN="'.$from_name.'":MAILTO:'.$from_address. "\r\n" .
        'ATTENDEE;CN="'.$to_name.'";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:'.$to_address. "\r\n" .
        'LAST-MODIFIED:' . date("Ymd\TGis") . "\r\n" .
        'UID:'.date("Ymd\TGis", strtotime($startTime)).rand()."@".$domain."\r\n" .
        'DTSTAMP:'.date("Ymd\TGis"). "\r\n" .
        'DTSTART:'.$date."T".$startTime."00Z\r\n" .
        'DTEND:'.$date."T".$endTime."00Z\r\n" .
        'TRANSP:OPAQUE'. "\r\n" .
        'SEQUENCE:1'. "\r\n" .
        'SUMMARY:' . $subject . "\r\n" .
        'LOCATION:' . $location . "\r\n" .
        'CLASS:PUBLIC'. "\r\n" .
        'PRIORITY:5'. "\r\n" .
        'BEGIN:VALARM' . "\r\n" .
        'TRIGGER:-PT15M' . "\r\n" .
        'ACTION:DISPLAY' . "\r\n" .
        'DESCRIPTION:Reminder' . "\r\n" .
        'END:VALARM' . "\r\n" .
        'END:VEVENT'. "\r\n" .
        'END:VCALENDAR'. "\r\n";
        $message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST'."\n";
        $message .= "Content-Transfer-Encoding: 8bit\n\n";
        $message .= $ical;

         $message=Yii::$app->mailer->compose()
        ->setFrom($from_address)
        ->setTo($to_address)
        ->setSubject('This is subject') // ???? ??????
        ->addTextHeader($headers)
        ->setHtmlBody($message)
        ->send();
        var_dump($message);
$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();
$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();