我使用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));
}
}
由于
答案 0 :(得分:-1)
如果您的服务器支持SSL,请尝试以下替代方法:
'port' => '465',
'host' => 'ssl://smpt.xxxx.com',