I have a Silex application with Swift Mailer, but it looks like the configuration was not loaded from $app['swiftmailer.options'].
I registered the service in my boot file
$app->register(new SwiftmailerServiceProvider());
And in my configuration file
$app['swiftmailer.options'] = array(
'host' => 'smtp.mandrillapp.com',
'port' => '587',
'username' => 'MY_USERNAME',
'password' => 'MY_PASSWORD',
'encryption' => null,
'auth_mode' => null
);
And then I send my email address using
$message = \Swift_Message::newInstance()
->setSubject($this->app['forum_name'] . ' Account Verification')
->setFrom(array('no-reply@domain.com'))
->setTo(array('recipient@example.com'))
->setBody('My email content')
->setContentType("text/html");
$this->app['mailer']->send($message);
The send function returns 1, but the message was never sent. But when I try to manually create an instance Swift_SmtpTransport, an email will be sent.
$transport = \Swift_SmtpTransport::newInstance('smtp.mandrillapp.com', 587)
->setUsername('MY_USERNAME')
->setPassword('MY_PASSWORD');
...
$mailer = \Swift_Mailer::newInstance($transport);
$mailer->send($message);
So the problem is that it $app['swiftmailer.options']does not read and does not load. Did I miss something?
I follow the instructions here .
source
share