Issue
I have set up pear, and previously got stuck at:
require_once('Mail.php');
I managed to resolve this by fixing the paths in PHP.ini, but now YII is complaining:
include(LOGIN.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
I don't know which libary to install to get PEAR to pick up LOGIN.php, if that's the problem. It could also be that YII is not allowing the import of LOGIN.PHP because it might have its own? I'm grabbing at straws though. Any ideas?
Solution
YiiMail
is an availble extension to send mails with or without smtp, This is an emailing extension that wraps SwiftMailer
. This extension also allows you to create emails from view files.
download this from here
In your config file, include below code in component section
'mail' => array(
'class' => 'application.extensions.yii-mail.YiiMail',
'transportType'=>'smtp',
'transportOptions'=>array(
'host'=>'smtp.googlemail.com',
'username'=>'test@gmail.com',//
'password'=>'passwd',
'port'=>'465',
'encryption'=>'ssl',
),
'viewPath' => 'application.views.mail',
'logging' => true,
'dryRun' => false
),
And in controller action section use something like below
$message = new YiiMailMessage;
$message->view = 'registrationFollowup';
//userModel is passed to the view
$message->setBody(array('userModel'=>$userModel), 'text/html');
$message->addTo($userModel->email);
$message->addBcc('someone@gmail.com');
$message->from = Yii::app()->params['adminEmail'];
Yii::app()->mail->send($message);
the view registrationFollowup
resides in mail folder inside views folder, the view path is understood from the config file ('viewPath' => 'application.views.mail'
)
Answered By - arun Answer Checked By - Mildred Charles (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.