1. extract and copy the yii-mail folder to the protected/extensions folder.
2. add mail thingy in main.php at protected/config :
// autoloading model and component classes
...
'import'=>array(
..
..
'ext.yii-mail.YiiMailMessage',
),
...
'components'=>array(
...
...
'mail' => array(
'class' => 'ext.yii-mail.YiiMail',
'transportType' => 'smtp', // change to 'php' when running in real domain.
'viewPath' => 'application.views.mail',
'logging' => true,
'dryRun' => false,
'transportOptions' => array(
'host' => 'smtp.gmail.com',
'username' => 'test@gmail.com',
'password' => 'test',
'port' => '465',
'encryption' => 'tls',
),
),
),
...
3. enable OpenSSL in php configuration.
4. run the example code in your view file:
$message = new YiiMailMessage;
$message->setBody('Message content here with HTML', 'text/html');
$message->subject = 'My Subject';
$message->addTo('test@gmail.com');
$message->from = Yii::app()->params['adminEmail'];
Yii::app()->mail->send($message);
this should send an email to test@gmail.com.


0 comments:
Post a Comment