【发布时间】:2015-07-14 10:49:58
【问题描述】:
我正在尝试将 HTML 和 Ics 格式的电子邮件发送到 gmail、outlook、yahoo、thunderbird、outlook express 2013 和 iphone,但我只能将 ics 格式发送到 gmail、outlook 和 yahoo。
问题我无法在同一邮件中发送 html 格式
我尝试了以下代码
public function createScheduleNotification(){
$from = 'info@careervita.com';
$fromName = 'info';
$to = 'testcareervita@outlook.com';
$subject = 'Invitation for Test Demo';
$desc = 'THIS IS TEST DEMO INVITAION';
$uid = date('Ymd').'T'.date('His')."-".rand();
$message = "BEGIN:VCALENDAR\r\n";
$message.= "PRODID:-//Zoho CRM//NONSGML Calendar//EN\r\n";
$message.= "VERSION:2.0\r\n";
$message.= "X-WR-TIMEZONE:GMT\r\n";
$message.= "X-WR-CALNAME:ZCRM\r\n";
$message.= "METHOD:REQUEST\r\n";
$message.= "CALSCALE:GREGORIAN\r\n";
$message.= "BEGIN:VEVENT\r\n";
$message.= "UID:".$uid."\r\n";
$message.= "DESCRIPTION:".$desc."\r\n";
$message.= "ORGANIZER;CN= Manisha:mailto:manisha.g@careervita.com\r\n";
$message.= "DTSTART:20150710T100010Z\r\n";
$message.= "DTEND:20150710T110000Z\r\n";
$message.= "ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;CN=Vinod T:mailto:g_manisha@outlook.com\r\n";
$message.= "ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;CN=Vivek J:mailto:manisha.gaidhane8788@gmail.com\r\n";
$message.= "LOCATION:CV360\r\n";
$message.= "CREATED:20150701T060720Z\r\n";
$message.= "LAST-MODIFIED:20150701T060720Z\r\n";
$message.= "X-EVENT-OWNER:1563791000000084003\r\n";
$message.= "END:VEVENT\r\n";
$message.= "END:VCALENDAR";
Yii::import('application.extensions.phpmailer.JPhpMailer');
$mailer = new JPhpMailer(true);
if (Yum::module()->phpmailer['transport'])
switch (Yum::module()->phpmailer['transport']){
case 'smtp':
$mailer->IsSMTP();
break;
case 'sendmail':
$mailer->IsSendmail();
break;
case 'qmail':
$mailer->IsQmail();
break;
case 'mail':
default:
$mailer->IsMail();
}
else
$mailer->IsMail();
$mailer->IsHTML(true);
$mailerconf=Yum::module()->phpmailer['properties'];
if(is_array($mailerconf))
foreach($mailerconf as $key=>$value) {
if(isset(JPhpMailer::${$key}))
JPhpMailer::${$key} = $value;
else
$mailer->$key=$value;
}
$mailer->SetFrom($from);
$mailer->AddAddress($to);
$mailer->Subject = $subject;
$mailer->Body = $message;
$mailer->AddCC('testcareervita@gmail.com', 'Person One');
$mailer->AddCC('testcareervita@yahoo.in', 'Person Two');
$mailer->ContentType = 'text/calendar';
$mailer->CharSet = 'UTF-8';
$mailer->addCustomHeader("MIME-version : 1.0");
$mailer->addCustomHeader('Content-type : text/calendar; name="testcal.ics"; method=REQUEST;');
$mailer->addCustomHeader('Content-Transfer-Encoding:7bit'); //to interpret ics file
$mailer->addCustomHeader("Content-class: urn:content-classes:calendarmessage");
$mailer->addCustomHeader('Content-Disposition : inline; filename="testcal.ics"');
return $mailer->Send();
}
- 如何在同一封电子邮件中发送 HTML 数据?
- outlook .ics 文件也无法下载
任何帮助都将不胜感激
【问题讨论】:
标签: php email yii outlook phpmailer