【问题标题】:PHP Fatal error: Class 'SMTP' not found in /home/screcafb/public_html/class.phpmailer.php on line 1520PHP 致命错误:在第 1520 行的 /home/screcafb/public_html/class.phpmailer.php 中找不到类“SMTP”
【发布时间】:2017-05-30 18:51:04
【问题描述】:

当我使用 PHP 邮件程序从网页发送电子邮件时出现内部服务器错误/我没有找到任何解决方案,我不知道如何在 Bigrock 服务器中配置邮件以制作 PHP 邮件程序工作。

这是代码。

<?php
if(isset($_POST['submit']))
{
require 'PHPMailerAutoload.php';
ini_set('SMTP','localhost' ); 
ini_set('sendmail_from', 'example@example.com');
$to="example1@example.com";
$fromrec=$_POST['from'];
$from="example@example.com";
$subject=$_POST['sf'];
$message=$_POST['message'];
$mail->isSMTP();
$mail = new PHPMailer;
$mail->setFrom($from, 'test');
$mail->addAddress($to);
$mail->Subject  = $subject;
$mail->Body     = "From:".$fromrec."".$message;
if(!$mail->send()) {
 echo 'Message was not sent.';
 echo 'Mailer error: ' . $mail->ErrorInfo;
 } else {
 echo 'Message has been sent.';
}
}
?>

日志中的错误是:

[2017 年 5 月 30 日 19:08:10 Etc/GMT] PHP 致命错误:在第 1520 行的 /home/screcafb/public_html/class.phpmailer.php 中找不到类“SMTP”

【问题讨论】:

  • 查看服务器日志,会显示错误信息。

标签: php phpmailer


【解决方案1】:

你有电话

$mail->isSMTP();

在您为变量$mail 赋值之前。你需要在之后移动它

$mail = new PHPMailer;

【讨论】:

  • 感谢您的快速回复。即使在修改后,我也会遇到相同的内部服务器错误
  • 您可能在某处遇到语法错误。服务器错误日志说明了什么?
  • [2017 年 5 月 30 日 19:08:10 Etc/GMT] PHP 致命错误:在第 1520 行的 /home/screcafb/public_html/class.phpmailer.php 中找不到类“SMTP”是错误日志中的错误
  • this question 有帮助吗?
  • 非常感谢,错误已更正,但我没有收到邮件
猜你喜欢
  • 2014-06-21
  • 2015-10-05
  • 1970-01-01
  • 2014-08-25
  • 1970-01-01
  • 1970-01-01
  • 2016-06-01
  • 2015-05-31
  • 2014-08-05
相关资源
最近更新 更多