kl_sendmail 插件收发邮件无效的解决办法

2021-3-22 Jon php

在 emlog5.3.1 插件 kl-sendmail 无论如何修改参数都是无效的,本仓库釜底抽薪,将发送邮件最核心的代码通过 PHPMailer 来代替,很好的解决了这个问题

拿来主义者
  1. 下载 kl-sendmail-heighten 仓库中将其传入到 content/plugins/ 目录中
  2. 后台需要插件中开启 Sendmail 并点击配置
  3. 填写对应配置并保存,注意发信密码为授权码而不是邮箱登录密码
  4. 发送测试邮件->邮箱查看邮件
  5. 完成
修改 kl_sendmail.php 文件的关键代码
   php    49行
// 引入 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)

标签: php mail sendmail

分享这篇文章
赞助鼓励:如果觉得内容对您有所帮助,您可以支付宝(左)或微信(右):

声明:如无特殊注明,所有博客文章版权皆属于作者,转载使用时请注明出处。谢谢!

评论:

林华华
2021-06-22 13:17
厉害

发表评论:

皖ICP备15010162号-1 ©2015-2022 知向前端
qq:1614245331 邮箱:13515678147@163.com Powered by emlog sitemap