I use it like this:

$this->Email->to = '[EMAIL PROTECTED]';
                          $this->Email->subject = $this-
>data['Contact']['subject'];
                                        $this->Email->replyTo = $this-
>data['Contact']['email'];
                                        $this->Email->from =
'Website';
                                        $this->Email->template =
'contact';
                                        $this->Email->sendAs =
'both';
$message = array();
$message[] = $this->data['Contact']['message'];
return ($this->Email->send($message));



On 28 avr, 21:49, Mech7 <[EMAIL PROTECTED]> wrote:
> I have been trying out the email component but i can't get the body of
> the email to send? I am using cake fro svn.
> When the email arrives it works ok except the body of the email is
> empty?
>
> This is my controller:
>
> <?php
> class ContactController extends AppController {
>
>         /**
>          * Use the email component to send the email
>          *
>          * @var array
>          * @access public
>          */
>         public $components = array('Email');
>
>         /*
>          * Use the form helper for contact form
>          *
>          * @var array
>          * @access public
>          */
>         public $helpers = array('Form');
>
>         /**
>          * Index action for contact form
>          *
>          * @access public
>          */
>         public function index($send = null){
>
>                 if($send == 'send'){
>                         $this->set('status', 'succes');
>                 } elseif ($send == 'failed'){
>                         $this->set('status', 'failed');
>                 } else {
>                         $this->set('status', 'form');
>
>                         if(!empty($this->data)){
>
>                                 // Set data to model for valiation
>                                 $this->Contact->set( $this->data );
>
>                                 if ($this->Contact->validates()) {
>
>                                         $this->Email->to = '[EMAIL 
> PROTECTED]';
>                                         $this->Email->subject = 
> $this->data['Contact']['subject'];
>                                         $this->Email->replyTo = 
> $this->data['Contact']['email'];
>                                         $this->Email->from = 'Website';
>                                         $this->Email->template = 'contact';
>                                         $this->Email->sendAs = 'both';
>                                         $this->set('message', 
> $this->data['Contact']['message']);
>                                         if($this->Email->send()){
>                                                 
> $this->redirect('/contact/index/send');
>                                         } else {
>                                                 
> $this->redirect('/contact/index/failed');
>                                         }
>                                 }
>                         }
>                 }
>         }}
>
> ?>
>
> And then in elements i have:
>
> email/text/contact.ctp
>
> <?php
> echo $message;
> ?>
>
> email/html/contact.ctp
>
> <?php
> echo htmlentities($message, ENT_QUOTES);
> ?>
>
> I also have the layouts/email/html and text files...
--~--~---------~--~----~------------~-------~--~----~
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