Hi My emails works, but the message/body/content part of the email
does not come through, the  $this->Email->template = 'thanks'; does
not come through...can anyone please help.

<?php
class ContactsController extends AppController
{
    var $name = "Contacts";
    var $uses = 'Contact';
    var $components = array('Email');


      //-----------------------------------------
  function index(){
    $this->set('title_for_layout', 'Contacts');
    if(isset($this->data)) {
    if($this->Contact->create($this->data) && $this->Contact-
>validates()){
      //send e-mail
      $this->_sendMail();
    }
    else {
    $this->Session->setFlash('Please correct the underlying errors');
    $this->redirect('/contacts/');
          }
      }
  }

  function _sendMail() {

    $senderEmail = $this->data['Contact']['mail'];

    $this->Email->to = $this->Session->read('Auth.User.email');
    $this->Email->subject = $this->data['Contact']['subject'];
    $this->Email->from = $senderEmail;
        $this->Email->replyTo = $this->Session->read('Auth.User.email');
         $this->Email->template = 'thanks';
    //Send as 'html', 'text' or 'both' (default is 'text')
    $this->Email->sendAs = 'text';
    //Set view variables as normal
    $this->set('fname', ucfirst($this->data['Contact']['fname']));
    $this->set('lname', ucfirst($this->data['Contact'] ['lname']));
    $this->set('mail', $senderEmail);
    $this->set('subject', $this->data['Contact']['subject']);

        //$this->$body=$this->data['Contact']['message']. "Email info: First
Name: ". ucfirst($this->data['Contact']['fname']). "Last
Name" .ucfirst($this->data['Contact'] ['lname']);
    //$this->set('message', $this->body);

        $this->set('content', $this->data['Contact']['content']);
    //Do not pass any args to send()
    if ( $this->Email->send() {
    $this->Session->setFlash('Your email was send successfully');
    $this->redirect('/contacts/');
    exit;
    } else {
    $this->Session->setFlash("There was error
    in sending the email. Please try again");
    $this->redirect('/contacts/');
    exit;
    }
  }
}
?>

~~~~~~~~~~~~~~~~model############################

<?php
class Contact extends AppModel {

  var $name = 'Contact';
  var $useTable = false;
  var $validate = array(
    'fname' => array('required' => VALID_NOT_EMPTY),
    'lname' => array('required' => VALID_NOT_EMPTY),
    'mail' => array('required' => VALID_NOT_EMPTY,
'validEmail'=>VALID_EMAIL),
    'subject' => array('required' => VALID_NOT_EMPTY),
    'content' => array('required' => VALID_NOT_EMPTY)
  );
   }
?>

#######################view ################################

<h1>Contact Us</h1>

<?php echo $form->create('Contact', array('url'=>'/contacts'));?>
<?php

echo $form->input('fname', array('label' => 'First Name', 'error' =>
array('required' => 'Please specify your First name')));
echo $form->input('lname', array('label' => 'Last Name', 'error' =>
array('required' => 'Please specify your Last name')));
echo $form->input('mail', array('label' => 'Email', 'error' =>
array('required' => 'Please specify your email address', 'validEmail'
=> 'Insert a valid email')));
echo $form->input('subject', array('label' => 'Subject', 'error' =>
array('required' => 'Insert email subject')));
echo $form->input('content', array('label' => 'Message', 'error' =>
array('required' =>'Insert your message here'), 'type'=>'textarea',
'cols'=>30));
?>
<div class="submit"><input type="submit" value="Send" /></div>
</form>
--~--~---------~--~----~------------~-------~--~----~
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