CakeEmail sends email without message

0

I'm trying to make a form for sending 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 inserts, nor the body of the message, appear. Only This email was sent using the CakePHP Framework, http://cakephp.org. appears. How do I resolve this issue?

I'm using CakePHP version 2.4.4.

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>
    
asked by anonymous 17.04.2014 / 18:50

1 answer

2

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

So you can do something like this:

->template('show_contact_us')

Since this file must be in the app/View/Emails/html/ directory.

    
22.04.2014 / 21:30