Reputation: 16307
PHP mail function is not working in yii framework www.test.com/index.php?r=Email
class EmailController extends Controller {
public function actionIndex(){
$this->sendEmail();
}
public function sendEmail(){
mail('test@gmail', 'hello', 'today i am very unhappy');
}
}
But mail function is working in simple file example www.test.com/email-test.php
Upvotes: 1
Views: 1144
Reputation: 1074
Ok if your email function is not working for www.test.com/index.php?r=Email but is working for www.test.com/email-test.php than it has to do with the URL rules in your main config file.
try the following;
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
'rules'=>array(
'gii'=>'gii',
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'<action>'=>'site/<action>',
),
),
or try this
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
this goes in your main config file under protected.
Upvotes: 1