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'));
}