【问题标题】:Error in sending SMTP mail发送 SMTP 邮件时出错
【发布时间】:2016-08-25 12:03:15
【问题描述】:

尝试使用 SMTP 从窗口服务器发送邮件。 我得到这个错误

Fatal error: Class 'SMTP' not found in...

当我只使用 PHPmailerAutoload.php 时它会给出

Fatal error: Call to undefined method SMTP::setDebugLevel() in...

我的代码是

error_reporting(E_ALL);
ini_set('display_errors','1');
require_once('class.phpmailer.php');
include("class.smtp.php"); 

$mail = new PHPMailer(); 
$mail->IsSMTP();
$mail->SMTPDebug  = 1;
$mail->SMTPAuth   = true;
$mail->Host       = "mail.host.com.au";
$mail->Port       = 25;
$mail->Username   = "myusername";
$mail->Password   = "mypassword";
$mail->SetFrom('info@company.com.au', 'First Last');
$mail->AddReplyTo("info@company.com.au","First Last");
$mail->Subject    = "PHPMailer Test Subject";
$body             = "test";
$mail->MsgHTML($body);

$address = "myemail@gmail.com";
$mail->AddAddress($address, "John Doe");

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

请提供任何建议。

【问题讨论】:

  • 你在这一行错过了" 替换$mail->Subject = "PHPMailer Test Subject";
  • 将 SMTPDebug 设置为 false $mail->SMTPDebug = false;
  • 没有发生同样的错误显示...
  • 我的代码很完美,然后我在谷歌上看到有几个版本的 phpmailer 类可用,所以我尝试了不同的版本,它工作了。
  • 感谢您的宝贵时间。

标签: php email smtp phpmailer smtp-auth


【解决方案1】:

我遇到了同样的问题..我解决了.. 打开你的 PHPMailer 并在那个 class.phpmailer.php 中,在 php 块的开头添加这一行: require_once('class.smtp.php'); 它肯定会起作用..或者您可以从此链接下载这两个文件: https://github.com/abhishekpanjabi/e-Legal.git

下载 phpmailer,它只有两个必需文件并将其替换为您的 phpmailer 文件。它会工作I've uploded image showing code.

【讨论】:

  • 我已经在文件 class.phpmailer.php 中添加了,但它现在说“致命错误:调用未定义的方法 SMTP::setTimeout() in...”
  • 我无法打开你的 github 链接。你能检查一下吗?
  • 您是否从上面显示的代码中删除了 include("class.smtp.php") ??
  • 我的代码很完美,然后我在谷歌上看到有几个版本的 phpmailer 类可用,所以我尝试了不同的版本,它工作了。
  • 我可以打开这个 github 链接.. 它工作正常.. 我尝试了 3 种不同的浏览器,我都工作了.. 不知道你的问题是什么。
猜你喜欢
  • 2015-03-05
  • 1970-01-01
  • 2015-02-21
  • 1970-01-01
  • 2014-01-04
  • 2012-07-28
  • 2021-12-31
  • 1970-01-01
相关资源
最近更新 更多