I'm trying to implement swift mailer into my website so I can send password recovery emails to registered users. I'm using dreamweaver. What I have done:
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
Here's my file structure
Main Folder
|classes
|Swift
|Private
|Recovery.php
And here's the code for 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);
But this is not including the libraries because if i do Swift_SmtpTransport::
then dreamweaver should popup an intellisense thing that gives me options of methods or variables, meaning it can see the class and all of it's member items. But since it doesn't popup the options, i get the feeling it cannot see what swift class is. And when I tried to run it, the console network tab said it was pending for a while before it returned a 500 Internal Server Error
. So it's not including the libraries properly. Any idea what I'm doing wrong?
Edit: Error reporting output:
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