0

嗨,我正在尝试用 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!";
  }
?>
4

2 回答 2

1

包括 phpmailer 类!

require_once($_SERVER['DOCUMENT_ROOT'].'/lib/phpmailer/class.phpmailer.php');

http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html

于 2013-03-14T22:03:21.317 回答
0

您是否尝试过在创建实例之前包含该类?例如:

require_once 'C:\PATH\TO\CLASS\PHPMailer.php';
于 2013-03-14T22:02:59.800 回答