Discuz Discuz! 6.1 - 发送HTML格式电子邮件
人气:0想了解Discuz! 6.1 - 发送HTML格式电子邮件的相关内容吗,在本文为您仔细讲解Discuz的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Discuz,HTML格式,电子邮件,下面大家一起来学习吧。
复制代码 代码如下:
--- sendmail.inc.original.php
+++ sendmail.inc.mime.php
@@ -33,23 +33,23 @@
$email_subject = '=?'.$charset.'?B?'.base64_encode(str_replace("\r", '', str_replace("\n", '', '['.$bbname.'] '.$email_subject))).'?=';
$email_message = chunk_split(base64_encode(str_replace("\r\n.", " \r\n..", str_replace("\n", "\r\n", str_replace("\r", "\n", str_replace("\r\n", "\n", str_replace("\n\r", "\r", $email_message)))))));
$email_from = $email_from == '' ? '=?'.$charset.'?B?'.base64_encode($bbname)."?= <$adminemail>" : (preg_match('/^(.+?) \<(.+?)\>$/',$email_from, $from) ? '=?'.$charset.'?B?'.base64_encode($from[1])."?= <$from[2]>" : $email_from);
foreach(explode(',', $email_to) as $touser) {
$tousers[] = preg_match('/^(.+?) \<(.+?)\>$/',$touser, $to) ? ($mailusername ? '=?'.$charset.'?B?'.base64_encode($to[1])."?= <$to[2]>" : $to[2]) : $touser;
}
$email_to = implode(',', $tousers);
-$headers = "From: $email_from{$maildelimiter}X-Priority: 3{$maildelimiter}X-Mailer: Discuz! $version{$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/plain; charset=$charset{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}";
+$headers = "From: $email_from{$maildelimiter}X-Priority: 3{$maildelimiter}X-Mailer: Discuz! $version{$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: ".(true === is_string($sendmail_mime) ? $sendmail_mime : 'text/plain')."; charset=$charset{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}";
$mail['port'] = $mail['port'] ? $mail['port'] : 25;
if($mail['mailsend'] == 1 && function_exists('mail')) {
@mail($email_to, $email_subject, $email_message, $headers);
} elseif($mail['mailsend'] == 2) {
if(!$fp = fsockopen($mail['server'], $mail['port'], $errno, $errstr, 30)) {
$errorlog('SMTP', "($mail[server]:$mail[port]) CONNECT - Unable to connect to the SMTP server", 0);
之后可以通过设定全局变量$sendmail_mime来发送HTML格式电子邮件。
加载全部内容