i found the answer. this is my code to send mail to all client.

function sendall() {
                $this->Client->recursive = 0;
        $this->set('clients', $this->Client->find('all'));
                foreach ($clients as $client) {
                        $this->Email->reset();
                        $this->Email->to = $client['Client']['email'];
                        $this->Email->subject = 'update request';
                        $this->Email->replyTo = '[email protected]';
                        $this->Email->from = 'xxxxxxxxxx <a...@xxxxx>';
                        $this->Email->template = 'simple_message';
                        $this->Email->sendAs = 'html';
                        $this->set('client', $client);
                        $this->Email->send();
                }
                if ( $this->Email->send() ) {
                        $this->Session->setFlash('email been sent');
                } else {
                        $this->Session->setFlash('email not sent');
                }
                $this->redirect(array('action'=>'index'));
        }

On Wed, Aug 4, 2010 at 12:59 AM, fadhli <[email protected]> wrote:

> hi everyone.
>
> i want to send email to all my client, the email contains client data, so
> the email different between the client. how to send email to all client at
> ones? i have read
> http://book.cakephp.org/view/1285/Sending-Multiple-Emails-in-a-loop but i
> don't know how to repeat sending email in my controller. can you give me an
> example? thanks.
>
> This is my code for sending an email to one client
>
>  function _sendmail($id) {
>>
>>                 $client = $this->Client->read(null, $id);
>>
>>                 $this->Email->to = $client['Client']['email'];
>>
>>                 $this->Email->subject = 'update request';
>>
>>                 $this->Email->replyTo = '[email protected]';
>>
>>                 $this->Email->from = 'XXXXX <[email protected]>';
>>
>>                 $this->Email->template = 'simple_message';
>>
>>                 $this->Email->sendAs = 'html';
>>
>>                 $this->set('client', $client);
>>
>>                 $this->Email->send();
>>
>>         }
>>
>>
>>>         function send($id) {
>>
>>                 if (!$id) {
>>
>>  $this->Session->setFlash(sprintf(__('Invalid %s', true), 'client'));
>>
>>  $this->redirect(array('action' => 'index'));
>>
>>  }
>>
>>                 $this->_sendmail($this->Client->id);
>>
>>                 $this->Session->setFlash(sprintf(__('The %s email update
>>> request has been send', true), 'client'));
>>
>>                 $this->redirect(array('action' => 'index'));
>>
>>         }
>>
>>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to