2

我正在使用 smtp 选项发送邮件。当我通过 ssl 发送邮件时,它工作正常。但是当我尝试通过 tls 发送邮件时,它无法正常工作。我的应用程序在 CakePHP 1.3 中。

function testemail() {
    $from = 'test@domain.com';
    $this->Email->delivery='smtp';
    $this->Email->smtpOptions = array(
      'port'=>'portnumber',
      'auth' => true,
      'host' => 'tls://smpt.xxxx.com',
      'username'=>'test@domain.com',
      'password'=>'xxxxxxxxx',
    );
    $this->Email->to = 'xxxxxx@gmail.com';
    $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));
    }
}

谢谢

4

1 回答 1

-1

如果您的服务器支持 SSL,请尝试此替代方法:

  'port' => '465',
  'host' => 'ssl://smpt.xxxx.com',
于 2018-09-26T16:43:05.420 回答