所以我正在尝试为我的注册表单实现PHPMailer,但在处理验证邮件时遇到错误。
它会将帐户添加到我的数据库中,但不会发送电子邮件。
我收到错误:
注意:使用未定义的常量phpmailer - 在第27行的/Applications/XAMPP/xamppfiles/htdocs/login/scripts/PHPMailer/PHPMailerAutoload.php中假设'phpmailer' 找不到文件phpmailer.php。
PHPMailerAutoload.php中的代码
function PHPMailerAutoload($MailSender)
{
//Can't use __DIR__ as it's only in PHP 5.3+
$filename = dirname(phpmailer).DIRECTORY_SEPARATOR.'class.'.strtolower($MailSender).'.php';
if (is_readable($filename)) {
require $filename;
}
}
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
//SPL autoloading was introduced in PHP 5.1.2
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register('PHPMailerAutoload', true, true);
} else {
spl_autoload_register('PHPMailerAutoload');
}
} else {
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
function __autoload($MailSender)
{
PHPMailerAutoload($MailSender);
}
}
这是我的文件结构:
固定!
代码应该是:
$filename = dirname(__FILE)__).DIRECTORY_SEPARATOR.'class.'.strtolower($MailSender).'.php';
答案 0 :(得分:0)
检查行
$filename = dirname(phpmailer).DIRECTORY_SEPARATOR.'class.'.strtolower($MailSender).'.php';
这样:
dirname(phpmailer)
你的意思是$phpmailer
吗?