尝试使用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!";
}
请提供任何建议。
答案 0 :(得分:0)
我有同样的问题这样做..我解决了.. 打开你的PHPMailer并在那个class.phpmailer.php中,然后在php块的开头添加这行:require_once('class.smtp.php'); 它肯定会工作..或者你可以从这个链接下载这两个文件: https://github.com/abhishekpanjabi/e-Legal.git
下载phpmailer它只有两个requird文件并用你的phpmailer文件替换它..它会工作I've uploded image showing code.