php - 在 phpmailer 中找不到类 SMTP

标签 php email gmail

我的 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

然后告诉你是否有错误。

关于php - 在 phpmailer 中找不到类 SMTP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29625285/

相关文章:

php - 在已经运行的查询循环中从第二个表调用循环查询

java - java mail 是否可以立即免费完成此商业电子邮件组件的功能?

javascript - Gmail如何在Opera上做 cometd ?

java - WebDriver + TestNG Gmail 一个奇怪的错误

php - 如何在 PHP 中去除字符串中的所有空格?

php - 我如何在 Symfony PHP 中生成一个友好的 URL?

php - 在php中使用PDO连接到数据库

php - Symfony 2 : Swiftmailer not sending, 没有错误

ios - 如何在 iOS 中以编程方式读取邮件消息?

android - 我如何在输入 "To"文件时获得电子邮件地址的建议?