我試圖在我的網站中實現快捷郵件,以便我可以向註冊用戶發送密碼恢復電子郵件。我正在使用Dreamweaver。我做了什麼:
PHP Swift Mailer設置
1) Downloaded Swift-4.2.2.tar
2) Extracted it
3) Uploaded to my host in /Domain/classes/lib
4) Included it in Recovery.php
這是我的文件結構
Main Folder
|classes
|Swift
|Private
|Recovery.php
這裏是爲Recovery.php
代碼:
require_once '../classes/lib/swift_required.php';
// Create the Transport
$email_to = $_POST["email"];
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465)
->setUsername('Username')
->setPassword('Password')
;
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance()
// Give the message a subject
->setSubject('Password Recovery')
// Set the From address with an associative array
->setFrom(array('[email protected]' => 'Username'))
// Set the To addresses with an associative array
->setTo($email_to)
// Give it a body
->setBody('Below is your temporary password. Please make sure to login in immediately and change it to a password of your choice.\n'.$password);
// Send the message
$result = $mailer->send($message);
但是,這還不包括因爲如果我這樣做的庫Swift_SmtpTransport::
然後Dreamweaver應該彈出一個intellisense的東西,給我的方法或變量的選項,這意味着它可以看到th e班和所有的成員項目。但是由於它沒有彈出選項,我感覺它無法看到什麼是快速類。當我試圖運行它時,控制檯網絡選項卡表示在返回500 Internal Server Error
之前它已等待一段時間。所以它不包括正確的庫。任何想法我做錯了什麼?
編輯: 錯誤報告輸出:
Warning: require(/*/*/*/Main Folder/classes/lib/classes/Swift.php): failed to open stream: No such file or directory in /*/*/*/Main Folder/classes/lib/swift_required.php on line 22
Fatal error: require(): Failed opening required '/*/*/*/Main Folder/classes/lib/classes/Swift.php' (include_path='.:/usr/local/lib/php') in /*/*/*/Main Folder/classes/lib/swift_required.php on line 22
是否啓用了error_reporting? error.log在發生500次錯誤時會說什麼?而且,順便說一句,IDE的行爲是不相關的。 – mario
@mario我沒有啓用error_reporting。但我不認爲這會有所幫助,因爲'Recovery.php'正在使用主頁面中的ajax進行調用。我如何顯示任何error_reporting輸出? – Richard
直接訪問'Recovery.php'。 –