你好,我创建了一个可以用icalendar发送电子邮件的程序。但在Gmail的描述部分,看起来与我想要实现的html代码相同。如何将html代码写入此部分?或者至少我想学习如何使用新行('n)
。它也不读新行。。。谢谢
$cal_uid = date('Ymd').'T'.date('His')."-".rand()."@mydomain.com";
$mime_boundary = "----Meeting Booking----".md5(time());
$headers .= "MIME-Version: 1.0'n";
$headers = "From: ".$from_name." <".$from_address.">'n";
$headers .= "Reply-To: ".$from_name." <".$from_address.">'n";
$headers .= "Content-Type: multipart/alternative; boundary='"$mime_boundary'"'n";
$headers .= "Content-class: urn:content-classes:calendarmessage'n";
$message .= "--$mime_boundary'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>Merhaba '.$firstname.' '.$lastname.',</p>';
$message .= $meeting_name;
$message .= "</body>'n";
$message .= "</html>'n";
$message .= "--$mime_boundary'n";
$ical = 'BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
ORGANIZER:MAILTO:'.$from_address.'
DTSTART:'.$dtstart.'
DTEND:'.$dtend.'
LOCATION:'.$meeting_location.'
TRANSP:OPAQUE
SEQUENCE:0
UID:'.$cal_uid.'
DTSTAMP:'.$todaystamp.'
DESCRIPTION:'.$meeting_description.'
SUMMARY:'.$subject.'
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR';
$message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST;charset=utf-8'n';
$message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST'n';
$message .= "Content-Transfer-Encoding: 8bit'n'n";
$message .= $ical;
//SEND MAIL
$mail_sent = @mail( $email, $subject, $message, $headers );
if($mail_sent) {
return true;
} else {
return false;
}
}
尝试此源
$subject = 'Website Change Request';
$headers = "From: " . strip_tags($_POST['req-email']) . "'r'n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "'r'n";
$headers .= "CC: susan@example.com'r'n";
$headers .= "MIME-Version: 1.0'r'n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1'r'n";
阅读有关使用HTML模板PHP 发送电子邮件的更多信息
您需要<br>
标记可以使用nl2br($string)
将字符串中的'n
或'r'n
转换为<br>
查看此处的文档