SMTP mail options with tls in cakephp 1.3

1.3k views Asked by At

I am sending mail using smtp options. When I sent mail via ssl it is working fine. But when I tried to send mail via tls, it is not working properly. My application is in CakePHP 1.3.

function testemail() {
    $from = '[email protected]';
    $this->Email->delivery='smtp';
    $this->Email->smtpOptions = array(
      'port'=>'portnumber',
      'auth' => true,
      'host' => 'tls://smpt.xxxx.com',
      'username'=>'[email protected]',
      'password'=>'xxxxxxxxx',
    );
    $this->Email->to = '[email protected]';
    $this->Email->subject = 'Test Email';
    $this->Email->from =  $from;            
    $this->Email->replyTo =  $from;         
    $this->Email->return = $from;
    $this->Email->additionalParams = '-f'.$from;
    $this->Email->sendAs = 'html';
    $this->Email->template = 'template';
    $this->set('template','Testing TLS mail');

    if($this->Email->send()) {
        $this->Session->setFlash(__('Mail sent.', true));
    } else {
        $this->Session->setFlash(__('Error.', true));
    }
}

Thanks

1

There are 1 answers

0
Paulo Pastoriza On

try this alternative if your server supports SSL:

  'port' => '465',
  'host' => 'ssl://smpt.xxxx.com',