2017-03-08 67 views
0

因此,我試圖爲我的註冊表單實現PHPMailer,但在處理驗證電子郵件時出現錯誤。試圖整合PHPMailer與我的登錄/註冊表格

它會將帳戶添加到我的數據庫中,但沒有發送電子郵件。

我得到的錯誤:

注意:使用未定義的常量的PHPMailer的 - 假設 '的PHPMailer' 中/Applications/XAMPP/xamppfiles/htdocs/login/scripts/PHPMailer/PHPMailerAutoload.php第27行 的文件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); 
    } 
} 

這是我的文件結構:

Click

修復!

代碼應該是:

$filename = dirname(__FILE)__).DIRECTORY_SEPARATOR.'class.'.strtolower($MailSender).'.php'; 

回答

0

檢查線

$filename = dirname(phpmailer).DIRECTORY_SEPARATOR.'class.'.strtolower($MailSender).'.php';

這樣的:

dirname(phpmailer)

你的意思是$phpmailer

+0

這是正確的行,但它應該是文件名我很確定,因爲它是__FILE__當我下載它。 –

+0

@ J.Charnock嘗試'dirname('phpmailer')' –

+0

對不起,我過於複雜的東西,它應該被留作FILE。把它改回原來的樣子,它就可以工作!嘿Presto –