I have a Silex app with Swift Mailer, but it seems like the configuration was not loaded from $app['swiftmailer.options']
.
I registered the service in my bootstrap 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 with
$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 email was never sent. But, when I try manually creating an instance of Swift_SmtpTransport
, the email would send.
$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 the $app['swiftmailer.options']
is not read or loaded. Am I missing something here?
I'm following the instructions from here.