<?php
class MessagesController extends AppController {

        var $name = 'Messages';
        var $components = array('Email');

        function _sendNewMessage($id) {
                $message = $this->Message->read(null,$id);
                $this->Email->to = $message['Client']['email'];
                $this->Email->bcc = array('fad...@c-artsmag.com');
                $this->Email->subject = 'Welcome to our really cool thing';
                $this->Email->replyTo = 'supp...@example.com';
                $this->Email->from = 'Cool Web App <a...@example.com>';
                $this->Email->template = 'simple_message'; // note no '.ctp'
                //Send as 'html', 'text' or 'both' (default is 'text')
                $this->Email->sendAs = 'both'; // because we like to
send pretty mail
                //Set view variables as normal
                $this->set('message', $message);
                //Do not pass any args to send()
                $this->Email->send();
        }

        .......
        .......
        .......

        function add() {
                if (!empty($this->data)) {
                        $this->Message->create();
                        if ($this->Message->save($this->data)) {
                                $this->_sendNewMessage( $this->Message->id );
                                $this->Session->setFlash(sprintf(__('The %s has 
been saved',
true), 'message'));
                                $this->redirect(array('action' => 'index'));
                        } else {
                                $this->Session->setFlash(sprintf(__('The %s 
could not be saved.
Please, try again.', true), 'message'));
                        }
                }
                $users = $this->Message->User->find('list',
array('fields'=>array('User.id', 'User.username')));
                $clients = $this->Message->Client->find('list');
                $this->set(compact('users', 'clients'));
        }

    .......
    .......
    .......

}
?>





I use the cakephp 1.3.0 and yahoo web hosting.
i write the code above to send email, but it does not work properly. anyone
can help me so this method works well.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to