CakeEmail sends email without message

I'm trying to make a form to send an email. This is sent correctly and with the name of the person, which is inserted in the form, in the right place, in the subject of the email. However, neither the email that this person enters, nor the body of the message, appear. Only This email was sent using the CakePHP Framework, http://cakephp.org. appears. How to solve this problem?

I am using version 2.4.4 of CakePHP.

Controller

<?php
class ContactsController extends AppController {
public function ShowContactUs(){
    $this->layout='default';
    $this->set('title_for_layout', 'Contactos');
}
public function Contact() {

    $this->set('title_for_layout', 'Contactos');
    $this->loadModel('Contact');
    if($this->request->is('post')) {

        $this->Contact->set($this->request->data);
        if($this->Contact->validates(array('fieldList' => array('name','email','message')))) {

            $email = new CakeEmail();
            $email->config('gmail')
                ->from(array('[email protected]' => 'mysite'))
                ->to('[email protected]')
                ->subject('mysite.com - Contacto - ' .  $this->request->data['Contact']['name'])
                ->emailFormat('text')
                ->template('default')
                ->viewVars(array(
                    'notificationType' => 'Contacto',
                    'message' => $this->request->data['Contact']['message'],
                    'name' => $this->request->data['Contact']['name'],
                    'email' => $this->request->data['Contact']['email'],
                    'title_for_layout' => 'Contacto'
                ))
                ->send();
                //debug($email);
                //die;
                $this->request->data = null;

                $this->Session->setFlash(__('Contact submitted successfully.'), 'Flash/success');

        } else {

            $error = $this->Notification->validationErrors;
            $this->set('error', $error);

            $this->Session->setFlash(__('Fill all fields'), 'Flash/warning');

        }
    }

}

}
?>

View ShowContactUs()

<h3>Contactos</h3>

<style type="text/css">
div.inline { float:left;
    padding-left: 2%; }
.clearBoth { clear:both; }
h3{
  color:#A80000 ;
  text-align: left;
}
div{text-align:justify;}
</style>

<br>
<div>
<p>Contacto Permanente: xxxxxxxxx</p>
<p>Email: xxxxxxx</p>
</div>
<div id="contact-form">

<div class="well">

    <?php echo $this->Form->create('Contact', array('url' => array('controller' => 'Contacts', 'action' => 'Contact'), 'class' => 'form-horizontal')) ?>

        <?php echo $this->Form->input('name', array('label' => __('Name') . ' *', 'class' => 'input-xlarge')); ?>
        <?php echo $this->Form->input('email', array('label' => __('E-mail') . ' *', 'class' => 'input-xlarge')); ?>
        <?php echo $this->Form->input('message', array('label' => __('Message') . ' *', 'class' => 'input-xxlarge', 'type' => 'textarea', 'rows' => 3)); ?>

        <?php echo $this->Form->submit(__('Enviar'), array('class' => 'btn btn-success')) ?>

    <?php echo $this->Form->end() ?>
</div>

</div>
Author: SunT, 2014-04-17

1 answers

Note that by documentation, you need to set the template at the time you create the settings, and currently you use the template default, which is not the same as you created and showed in your question.

Then you can do something like this:

->template('show_contact_us')

And this file must be in the Directory app/View/Emails/html/.

 2
Author: Paulo Rodrigues, 2014-04-22 19:30:50