0

我一直在尝试使用 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。

有任何想法吗 ?

4

2 回答 2

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
    );
}

参考这里的功能拉请求> https://github.com/cakephp/cakephp/pull/734

于 2012-10-17T16:40:03.247 回答
2

您应该在 $default 配置中使用 "tls"=>true。

于 2012-09-17T11:44:05.767 回答