我想在我的CakePHP應用程序中使用Emailing System(CakeEmail Class)
。當新用戶在我的網站註冊時,會向他/她發送一封電子郵件,告知您「已保存,現在按照此鏈接登錄」。我添加了這個功能,但是它沒有發送任何郵件或者顯示代碼有什麼問題。這是代碼: p在CakePHP中發送電子郵件
App::uses('AppController','Controller','CakeEmail','Network/Email');p
.
.
.
public function signUp(){
if($this->request->is('post')){
$this->User->create();
if($this->User->save($this->request->data)){
$Email=new CakeEmail('default');
$Email->from(array('[email protected]'=>'My Site'))
->to($this->request->data['User']['username'])
->subject('Welcome to Beauty Class')
->send('My message');
$this->Session->setFlash(__('You have been saved and an email has just been sent to you, check your mail-box and follow the given link to login'));
$this->redirect();
}else{
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
}
$this->set('title_for_layout','Sign Up');
}
爲了執行電子郵件和setFlash語句,您是否驗證過所有if條件都是真的?你收到什麼輸出? –
'$ this-> request-> data ['User'] ['username']'是一個有效的電子郵件地址?試着抓住電子郵件,看看是否有任何輸出。 – Nunser
App :: uses() - 按照記錄 - 只有兩個參數。你需要幾個來覆蓋你的課程! – mark