Yii Framework Forum: YiiMailMessage and its behaviors do not have a method - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

YiiMailMessage and its behaviors do not have a method

#1 User is offline   Tatsiana 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 24-July 11

Posted 24 July 2011 - 11:31 AM

Help solve the problem with the message:
Exception:YiiMailMessage and its behaviors do not have a method or closure named "setSubject"
and
Exception:YiiMailMessage and its behaviors do not have a method or closure named "setTo"
and
Exception:YiiMailMessage and its behaviors do not have a method or closure named "setFrom"

In protected/main/config.php:
'import'=>array(
         ...
        'application.extensions.yii-mail.*',
	),
...
'components'=>array(
    ...
    'mail' => array(
        'class' => 'application.extensions.yii-mail.YiiMail',
        'transportType'=>'smtp', /// case sensitive!
        'transportOptions'=>array(
            'host'=>'smtp.gmail.com',
            'username'=>'yourgoogleemail@gmail.com',
            // or email@googleappsdomain.com
            'password'=>'yourgooglemailpassword',
            'port'=>'465',
            'encryption'=>'ssl',
            ),
        'viewPath' => 'application.views.mail',
        'logging' => true,
        'dryRun' => false
    ),


In controller:
$message = new YiiMailMessage;
 
//userModel is passed to the view
$message->setBody('My text');
  
$message->setTo(array($userModel->email=>'My name'));
$message->from = Yii::app()->params['adminEmail'];
Yii::app()->mail->send($message);


The result of the action:
    Exception:YiiMailMessage and its behaviors do not have a method or closure named "setSubject"
    Exception:YiiMailMessage and its behaviors do not have a method or closure named "setTo"
    Exception:YiiMailMessage and its behaviors do not have a method or closure named "setFrom"

0

#2 User is offline   huggie 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 03-August 09
  • Location:The Netherlands

Posted 11 August 2011 - 06:43 AM

I had a similar problem!

Try and look for any classes/files in your yii app that have the same name as this class. I accidentally made a copy of a class a while ago which had the class prices in it. The original file had the class Prices in it. Somewhere in my app i still had a reference to different upper and lowercase versions of the prices class. That happened because i developed on a windows machine and the live machine was linux (they treat filenames/loading differently).

Hope this helps!
0

#3 User is offline   Dhanush 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 24-January 14

Posted 18 April 2014 - 09:03 AM

i had similar error too but it solved now!! thanks mate...cheers!!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users