Component for Yii Framework based application which provides simple configuration interface for Swift Mailer library.
Add dependency to your composer.json
file:
{
"require": {
"sobit/swiftmailer-component": "dev-master"
}
}
Update your protected/config/main.php
file:
<?php
Yii::setPathOfAlias('vendor', dirname(__FILE__) . '/../../vendor');
return array(
'components' => array(
'mailer' => array(
'class' => 'vendor.sobit.swiftmailer-component.SwiftMailerComponent',
'swiftBasePath' => dirname(__FILE__) . '/../../vendor/swiftmailer/swiftmailer',
'host' => 'localhost', // smtp host
'port' => 25, // smtp port
'username' => null, // username
'password' => null, // password
'security' => null, // security, e.g. "ssl"
),
),
);
Most simple usage example:
$message = Yii::app()->mailer
->createMessage('Test subject', 'Test body content')
->setFrom(array('[email protected]' => 'John Doe'))
->setTo(array('[email protected]', '[email protected]' => 'A name'))
;
Yii::app()->mailer->send($message);