A strange one to be honest. I have got this working completely fine on my local machine but on the production server (CENTOS), the redirect after registering is hitting the email template..
Is there something I am missing here?
function register() {
$this->layout = 'login';
$this->set('title_for_layout', 'Register');
if(!empty($this->data)) {
$this->User->create();
if($this->User->save($this->data)) {
$this->data['User']['group_id'] = 4;
$this->_sendNewUserMail( $this->User->id );
$this->redirect(array('action' => 'approval'));
} else {
$this->Session->setFlash(__('There were errors found in your registration. Please check the highlighted fields', true));
}
}
}
function _sendNewUserMail($id) {
$this->Email->smtpOptions = array(
'port'=>'25',
'timeout'=>'30',
'host' => 'localhost',
'username'=>'username',
'password'=>'password',
);
$this->Email->delivery = 'smtp';
$User = $this->User->read(null,$id);
$this->Email->to = array('someone@blah.com');
$this->Email->subject = 'A new registration has been submitted';
$this->Email->from = 'Me@blah.com';
$this->Email->template = 'default';
$this->Email->sendAs = 'html';
$this->set('User', $User);
$this->Email->send();
}
I am completely stumped with this..
Many thanks for your help in advance!
I would guess php_openssl is not enabled. Also, you should move the smtpOptions and delivery setting into _sendNewUserMail