我不知道如何爲所有用戶發送一封電子郵件,我做這在我的控制器:如何發送電子郵件的所有用戶使用CakePHP
// Init
$data = $this->request->data['Email'];
$d = array(
'subject' => $data['subject'],
'message' => $data['message']
);
// QUERY
$all = $this->Spoutnik->find('all', array(
'conditions' => array(
'Spoutnik.role >=' => '1'
),
'fields' => array('Spoutnik.email')
));
$this->set(compact('all'));
// list
$bcc = '';
foreach ($all as $user) {
$bcc .= $user['Spoutnik']['email'].',';
}
// MAIL
App::uses('CakeEmail', 'Network/Email');
$CakeEmail = new CakeEmail('default');
$website_short_name = Configure::read('website.short_name');
$CakeEmail->bcc("$bcc");
$CakeEmail->subject(''.$website_short_name.' :: '.$d['subject'].'');
$CakeEmail->viewVars(array(
'message' => (''.$d['message'].'')
));
$CakeEmail->emailFormat('html');
$CakeEmail->template('message_direct');
// final
$CakeEmail->send();
但我有錯誤「沒有有效的郵件」,並在收聽用戶的郵件後
我的代碼有什麼問題?
選中此http://stackoverflow.com/questions/6211992/ how-to-send-a-multiple-emails-at-a-time-in-cakephp – AnNaMaLaI
謝謝,但我把這個問題的原始代碼解決方案,它不工作。 – UbuntuClash