Sending Mails From Yii

Property "CWebApplication.mail" is not defined.

I got this error while i was trying to integrate mail extentsion into my yii project…

can, any one help me please…

How to send mails from yii?

Hi

Please post the code you add in config/main, how use the extension and which is the extension ?

hi Elite, u r always ready to help… i appreciate that.

i just followed this link:

My link

here i am attaching my main.php & Sitecontroller.php files.

suggest me what should i modify to make it works…

Did you follow all steps of this extension documentation ?

trace your code, when the error displayed ? (in which of the line code ?)

i cant makeout what’s going wrong.

here, i am attaching the screen shots of that error page…

you must add ‘mail’ component definition inside ‘components’=>array( … ) section. placing it at the end causes your error, because CWebApplication class does not have ‘mail’ attribute and Yii tries to assign that part from config file to such attribute.

so you need to have your config like this:




'components'=>array(

    //all other components goes here...

    //...




    'mail' => array(

        'class' => 'ext.mail.YiiMail',

        'transportType' => 'smtp',

        'transportOptions'=>array(

            'host'=>'smtp.gmail.com',

            'encryption'=>'ssl', // use ssl

            'username'=>'bolenedisatyanarayana@gmail.com',

            'password'=>'xxxxxx',

            'port'=>465, // ssl port for gmail

        ),

        'viewPath' => 'application.views.mail',

        'logging' => true,

        'dryRun' => false,

      ),

), //end of 'components' array



You added


 'mail' => array(

        'class' => 'ext.mail.YiiMail',

        'transportType' => 'smtp',

        'transportOptions'=>array(

            'host'=>'smtp.gmail.com',

            'encryption'=>'ssl', // use ssl

            'username'=>'bolenedisatyanarayana@gmail.com',

            'password'=>'xxxxxx',

            'port'=>465, // ssl port for gmail

        ),

        'viewPath' => 'application.views.mail',

        'logging' => true,

        'dryRun' => false,

      ),

outside of the components region of the config/main.php, cut it and paste it into the components array like that




'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),

     ...

     'mail' => array(

        'class' => 'ext.mail.YiiMail',

        'transportType' => 'smtp',

        'transportOptions'=>array(

            'host'=>'smtp.gmail.com',

            'encryption'=>'ssl', // use ssl

            'username'=>'bolenedisatyanarayana@gmail.com',

            'password'=>'xxxxxx',

            'port'=>465, // ssl port for gmail

        ),

        'viewPath' => 'application.views.mail',

        'logging' => true,

        'dryRun' => false,

      ),

      ...



yes… that’s

i changed it.

it’s working fine now

Thanks…

yes, u r correct. now that error gone. Thanks…

how can i send a mail now?

what else i should do now, to send a mail?

here, where should i write test.php file?

http://www.yiiframework.com/wiki/468/send-mail-using-yiimail-extension/

According to the documentation


Yii::app()->mail->send($message);

Thanks for voting :)