在使用Composer安装后尝试向用户PHPmailer引发此错误。
这是我第一次尝试Composer。我相信我已经按照相关站点上的说明成功安装了Composer和PHPmailer。在我网站的根目录中,我现在有目录.composer,.subversion和vendor。其中的最后一个子目录phpmailer / phpmailer包含composer.json。 webroot是站点根目录下的子目录。
我在做什么错?现在我可以找出错误了吗?
编辑
这是我正在使用的示例代码:
<?php
require_once(dirname($_SERVER["DOCUMENT_ROOT"]) . '/config/setup.php');
require_once($_SERVER["DOCUMENT_ROOT"] . '/php/inc/errorhandler.php');
require_once dirname($_SERVER["DOCUMENT_ROOT"]) . '/vendor/autoload.php';
$mail = new PHPMailer(true); //LINE 7//
$mail->SMTPDebug = 2;
$msgrubric = 'This message is from the contact form on the website.' . "\n\n";
try
{
$mail->IsSendmail();
$mail->AddAddress(CONTACTFORM_ADDR);
$mail->CharSet = 'UTF-8';
$mail->AddReplyTo($fieldData['email']);
$mail->Subject = $fieldData['subject'];
$mail->SetFrom($fieldData['email'], $fieldData['name']);
$mail->Body = $msgrubric . $fieldData['message'];
$mail->Send();
}
catch (phpmailerException $e)
{
echo ("<h1>Send us email</h1>");
echo('<p>We regret that an error prevented submission of your message. ' .
'The fault has been logged and will be corrected as soon as possible. ' .
'Please try again later. ' . "\n");
trigger_error('Unable to send email in contact form', E_USER_WARNING);
return false;
}
return true;
这将显示错误消息Fatal error: Uncaught Error: Class 'PHPMailer' not found in /homepages/15/d00000000/htdocs/tvcdev/php/main/testmail.php:7