简体   繁体   中英

CakePHP Email Component

Any reason why when I include the Email component in my controller without writing any code for it:

var $components = array('Email');

I get a fatal error saying:

Fatal error: Call to a member function read() on a non-object

I assume this is relating to the $Session variable, when I comment the component out, the error disappears.

似乎Session组件默认情况下已加载,但是如果我在AppController中定义var $ components = array('Email')且不将Session包含在数组中,则会将其删除。

After your comments I suggest you write var $components = array('Email', 'Session') , this should get you rid of your error. The problem is, that the AppController components don't get merged with the defaults. That means, if you declare the components with just 'Email', your Session-component will be lost and you therefore get this error because $this->Session is not an object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM