I am implementing a mailing solution where if I call swiftmailer from the main index.php file like :
require_once '../swiftmailer/lib/swift_required.php';
...
$result = $mailer->send($message);
All is great. But when I use the same swiftmailer library in my application class to implement layout/design partition like this:
// File: controller.php
class Index {
...
public function ignition() {
...
spl_autoload_register(array($this, 'myClassLoaderFx'));
}
public function myClassLoaderFx($name) {
$classes = array(
'Blah' => '../blah/Blah.php',
...
'Swift' => '../swiftmailer/lib/swift_required.php'
);
if(!array_key_exists($name, $classes)){
die('Class not found');
}
require_once $classes[$name];
}
// File: Mailer.php
class Mailer {
...
public function main($recepient[], $sender, $subject, $body) {
...
$transport = Swift_SmtpTransport::newInstance('xyz.google.com', 465, "ssl")->setUsername($this->username)->setPassword($this->password);
...
$result = $mailer->send($message);
}
Upon execution I get : Class "Swift_SmtpTransport" not found. The library is loaded because I get all Swift class list in the netbeans context help. But, upon execution I get the error. I have done all possible spell checkings. Getting nowhere from here on. Please help.