此代码输出:
Call to a member function link() on a non-object
我想要的是在电子邮件中发送一个链接。代码有什么问题?谢谢
class User extends AppModel {
public $helpers = array('Html');
public function sendEmail($email_user, $code) {
$email = new CakeEmail();
$email->config('smtp');
$pwrurl = "http://xxx/users?se=check&mail=".$email_user."&code=".$code;
$link = $this->Html->link('Link name', $pwrurl, array('target' => '_blank'));
$email->from(array('xxxn@gmail.com' => 'xxxx'))
->to($email_user)
->emailFormat('html')
->send('My message:: '.$link);
return true;
}
}
更新:我得到同样的错误。
App::uses('CakeEmail', 'Network/Email');
App::uses('AppHelper', 'View/Helper');
class AppController extends Controller {
public $helpers = array('Form', 'Html');
public function sendEmail($email_user, $codeLink) {
//same code.
}
}