Tuesday, August 3, 2010

sending multiple email

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 = 'no-reply@xxxxx.com';
                $this->Email->from = 'XXXXX <acel@xxxxxx.com>';
                $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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: