在 emlog5.3.1 插件 kl-sendmail 无论如何修改参数都是无效的,本仓库釜底抽薪,将发送邮件最核心的代码通过 PHPMailer 来代替,很好的解决了这个问题
拿来主义者
- 下载 kl-sendmail-heighten 仓库中将其传入到 content/plugins/ 目录中
- 后台需要插件中开启 Sendmail 并点击配置
- 填写对应配置并保存,注意发信密码为授权码而不是邮箱登录密码
- 发送测试邮件->邮箱查看邮件
- 完成
修改 kl_sendmail.php 文件的关键代码
// 引入 phpmailer.php
require_once(EMLOG_ROOT.'/content/plugins/kl_sendmail/PHPMailer.php');
// kl_sendmail_do 函数 中将发送邮件代码删除
$mail = new KL_SENDMAIL_PHPMailer();
$mail->CharSet = "UTF-8";
$mail->Encoding = "base64";
$mail->Port = $port;
if(KL_MAIL_SENDTYPE == 1)
{
$mail->IsSMTP();
}else{
$mail->IsMail();
}
$mail->Host = $mailserver;
$mail->SMTPAuth = true;
$mail->Username = $mailuser;
$mail->Password = $mailpass;
$mail->From = $mailuser;
$mail->FromName = $fromname;
$mail->AddAddress($mailto);
$mail->WordWrap = 500;
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $content;
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if($mail->Host == 'smtp.qq.com') $mail->SMTPSecure = "ssl";
if(!$mail->Send())
{
echo $mail->ErrorInfo;
return false;
}else{
return true;
}
// 添加
$mail = array(
"subject"=>$subject,
"body"=>array(
'content'=>$content,
)
);
$test = new SendMaill(
$mailserver,
$port,
$mailuser,
$mailpass,
false,
false
);
$test->sendMail($mailto, $mail, true)
2021-06-22 13:17