加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

在phpmailer中找不到类SMTP

发布时间:2020-12-13 16:56:10 所属栏目:PHP教程 来源:网络整理
导读:我的 PHP邮件程序功能有这个问题.我尝试更改所需的文件,但仍然是相同的.任何人都可以帮我解决这个错误. 这是我的phpmailer代码: $mail = new PHPMailer();$mail-IsSMTP();$mail-SMTPDebug = 0;$mail-SMTPAuth = true;$mail-SMTPSecure = 'ssl'; $mail-Host
我的 PHP邮件程序功能有这个问题.我尝试更改所需的文件,但仍然是相同的.任何人都可以帮我解决这个错误.

这是我的phpmailer代码:

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl'; 
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->IsHTML(true);
$mail->Username = "testnoreply@gmail.com";
$mail->Password = "test";
$mail->SetFrom("testnoreply@gmail.com");
$mail->Subject = "Membership expire notice";
$mail->Body = "Dear ICONIS member your membership is going to expire please renew it";
$mail->AddAddress($em);

if (!$mail->Send()) {
  echo "Mailer Error: " .$mail->ErrorInfo;
} else {
  echo "Mail has been sent";
}

解决方法

你确定你的文件夹中有class.phpmailer.php和class.smtp.php吗?

在包含class.phpmailer.php之前尝试包括class.smtp.php,如下所示:

<?php
include 'class.smtp.php';
include 'class.phpmailer.php';
// your code goes here

然后告诉你是否有错误.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读