他正试图在php发送电子邮件,但我一直收到此错误
致命错误:第2行的C:\ wamp \ www \ Site \ php \ phpmailer.php中找不到类'PHPMailer'
这是我的代码:
<?php
$mail = new PHPMailer();
$mail->IsSMTP();
//GMAIL configerations
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "myaddress@gmail.com";
$mail->Password = "password";
//End Gmail
$mail->From = "address@gmail.com";
$mail->FromName = "Me";
$mail->Subject = "Trial";
$mail->MsgHTML("this is atest message");
$mail->AddAddress("my address@gmail.com","name to");
$mail->IsHTML(true);
if(!$mail->Send()) {//to see if we return a message or a value bolean
echo "Mailer Error: " . $mail->ErrorInfo;
} else{
echo "Message sent!";
}
?>
答案 0 :(得分:1)
包含phpmailer类!
require_once($_SERVER['DOCUMENT_ROOT'].'/lib/phpmailer/class.phpmailer.php');
http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html
答案 1 :(得分:0)
在创建实例之前,您是否尝试过包含该类?例如:
require_once 'C:\PATH\TO\CLASS\PHPMailer.php';