我正在尝试在我的网站中实施 swift mailer,以便我可以向注册用户发送密码恢复电子邮件。我正在使用 Dreamweaver。我做了什么:
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('Username@domain.com' => '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 应该弹出一个智能感知事物,它为我提供方法或变量的选项,这意味着它可以看到类及其所有成员项。但由于它没有弹出选项,我觉得它看不到 swift 类是什么。当我尝试运行它时,控制台网络选项卡说它在返回之前等待了一段时间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