我正在尝试使 PHPMailer 工作,但它一直给我这个错误:
致命错误:在第 8 行的 /home/a4588543/public_html/contact/mailtest/process.php 中找不到类 'PHPMailer'。
第8行是:
$mail = new PHPMailer();
这是代码:
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mysmtp-server"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "me@mydomain.com"; // SMTP username
$mail->Password = "pass"; // SMTP password
$mail->From = "me@mydomain.com";
$mail->FromName = "Online Request";
$mail->AddAddress("receiver@mydomain.com"); // name is optional
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Contact Form";
$mail->Body = $message;
$mail->AltBody = $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>