1

I am wondering how to increase the speed of my contact form. CakeEmail is sending two emails when you submit your adress and is then redirecting to the next view. Any suggestions how to improve this, so the user is directly redirected and the emails are sent seperately?

I appreciate your help! Thanks in advance!

// Controller

public function registerShort() {
    $this->layout = 'guest';

    if ($this->request->is('post')) {

        $Email = new CakeEmail();
        $Email->template('candidates_register_short', 'default')
            ->emailFormat('html')
            ->config('bewerber')
            ->from(array('bewerber@mueller.de' => 'Herr Müller'))
            ->to($this->request->data['Candidate']['email'])
            ->subject('Dankeschön')
            ->send();

        $Email = new CakeEmail();
        $Email->config('admin');
        $Email->from(array('admin@mueller.de' => 'Mueller.de'));
        $Email->to('bewerber@mueller.de');
        $Email->subject('Neuer Eintrag: Kandidat');
        $Email->send($this->request->data['Candidate']['email']);
        $this->redirect(array('controller' => 'candidates', 'action' => 'registerDetail'));
    }

    $this->loadModel('EnquiryType');
    $enquiryTypes = $this->EnquiryType->find('list');
    $this->set(compact('enquiryTypes'));
}
Flojkee
  • 11
  • 1
  • 2
    you could save the emails in the database (if it's custom written, the whole text, otherwise just the important data and leave the main text as an email view), and set a cron that checks every x minutes/hours/etc to see if the email was sent, if not, send it. – Nunser Aug 28 '14 at 15:16
  • Not an "answer", but I switched to using Mandrill and think it's a good route to go for emails – Dave Aug 28 '14 at 17:17
  • You can use CakeResque to queue the email jobs. Lots of options. I wrote a QueueEmail plugin that saves them in the db then cron sends them, but I'd suggest a proper job queue. – jeremyharris Aug 28 '14 at 23:02

0 Answers0