【发布时间】:2013-12-09 22:48:22
【问题描述】:
我正在开发一个 cakephp 2.3。我想将电子邮件组件加载到我位于 Lib 文件夹中的类中。供应商文件的情况也一样,目前我正在做的是这个..
App::uses('EmailComponent', 'Controller/Component');
class Email {
public static function sendemail($toEmail,$template,$subject) {
$this->Email->smtpOptions = array(
'port'=>'25',
'timeout'=>'30',
'host' => 'host',
'username'=>'username',
'password'=>'password'
);
$this->Email->template = $template;
$this->Email->from = 'no-reply@hello.com';
$this->Email->to = $toEmail;
$this->Email->subject = $subject;
$this->Email->sendAs = 'both';
$this->Email->delivery = 'smtp';
$this->Email->send();
}
我无法使用$this.. 我收到此错误
$this 不在对象上下文中时
【问题讨论】:
标签: cakephp cakephp-2.0 cakephp-2.3