I think you have 2 possibilities:
Eogeasp
Suppose you have a mail_users function in your UsersController
function mail_users($subject = 'Sample subject') { $users = $this->User->find('all', array('fields' => array('email')); foreach ($users as $user) { $this->Email->reset(); $this->Email->from = '< no-reply@noreply.com >'; $this->Email->to = $user['email']; $this->Email->subject = $subject ; $this->Email->sendAs = 'html'; $this->Email->send('Your message body'); } }
In this function, $this->Email->reset() is important.
using bcc
function mail_users($subject = 'Sample subject') { $users = $this->User->find('all', array('fields' => array('email')); $bcc = ''; foreach ($users as $user) { $bcc .= $user['email'].','; } $this->Email->from = '< no-reply@noreply.com >'; $this->Email->bcc = $bcc; $this->Email->subject = $subject; $this->Email->sendAs = 'html'; $this->Email->send('Your message body'); }
Now you can simply call this method with a link to /users/mail_users/subject
For more information, read the Email Component guide.
source share