Search code examples
emailcakephpconfirmation

How to send email using cakephp framework?


No clue how to send an email as soon as an order has been saved. The purchaser will enter in an email in the order form and a confirmation email is sent using CakePHP 2.0. I've tried so many different ways but I'm a noob and need direction. Please direct me!

  <?
    class OrdersController extends AppController
    {
       var $name = 'Orders';
       var $scaffold;
       function add()
       {            
          if ($this->request->is('post'))
          {
               if ($this->Order->save($this->request->data)) 
               {
                   $this->Session->setFlash('Order has been saved');
                   $this->redirect(array('action' => 'index'));
               }
               else 
               {
                   $this->Session->setFlash('Unable to add order');
               }
          }
       }
    }
  ?>

Solution

  • CakePHP provides a CakeEmail class for this purpose: http://book.cakephp.org/2.0/en/core-utility-libraries/email.html