CakePHP CakeMail向TLS Microsoft Exchange Server 2010发送电子邮件(Godaddy中的托管Exchange)

时间:2012-07-10 08:08:53

标签: php cakephp exchange-server

我一直在尝试使用CakePHP(CakeMail)向Microsoft Exchange 2010 Server发送电子邮件的几个配置选项。这是我目前的配置:

    public $default = array(
    'transport' => 'Smtp',
    'from' => array('email@example.com' => 'Me'),
    'host' => 'smtp.ex3.secureserver.net',
    'port' => 587,
    'timeout' => 30,
    'username' => 'verifiedUserName',
    'password' => 'verifiedPassword',
    'client' => null,
    'log' => true,
    'delivery' => 'smtp'
);

这是我的测试功能:

    public function test_email() {
    App::uses('CakeEmail', 'Network/Email');
    $email = new CakeEmail();
    $email->config('default');
    debug($email->config());
    $result = $email->template('checkout')
            ->from('email@example.com')
            ->emailFormat('text')
            ->to('another@example.com')
            ->subject('TEST EMAIL ')
            ->send();
}

我得到了

SMTP Error: 504 5.7.4 Unrecognized authentication type

如果我将主机更改为'ssl://smtp.ex3.secureserver.net'或'tls://smtp.ex3.secureserver.net'我正在获取

Unable to connect to SMTP server.

服务器配置为使用TLS。

有什么想法吗?

2 个答案:

答案 0 :(得分:3)

(摘自书) http://book.cakephp.org/2.0/en/core-utility-libraries/email.html#configuration

从2.3.0开始,您还可以使用tls选项启用TLS SMTP:

<?php
class EmailConfig {
    public $gmail = array(
        'host' => 'smtp.gmail.com',
        'port' => 465,
        'username' => 'my@gmail.com',
        'password' => 'secret',
        'transport' => 'Smtp',
        'tls' => true
    );
}

参考此处的特征提取请求&gt; https://github.com/cakephp/cakephp/pull/734

答案 1 :(得分:2)

您应该在$ default config中使用“tls”=&gt; true。