【问题标题】:CakePHP 2.0 Email SMTP ErrorCakePHP 2.0 电子邮件 SMTP 错误
【发布时间】:2012-01-04 04:56:54
【问题描述】:

当我尝试使用 CakeEmail 从 CakePHP 2.0 发送邮件时出现此错误:

SMTP 错误:502 5.5.1 无法识别的命令。 p1si477061pbk.249

我从 Gmail 发送,这是我的配置:

public $gmail = array(
    'transport' => 'Smtp',
    'host' => 'aspmx.l.google.com',
    'port' => 25,
    'timeout' => 30,
    'username' => 'user',
    'password' => 'secret',
    'client' => null,
    'log' => true
    //'charset' => 'utf-8',
    //'headerCharset' => 'utf-8',
);

这里的主机和端口来自这篇文章:http://www.google.com/support/a/bin/answer.py?answer=176600

【问题讨论】:

  • 发现问题。 Gmail 的非 SSL/TLS SMTP 服务不支持 CakePHP 分派的 AUTH LOGIN 命令。使用 SSL/TLS 应该没问题。

标签: php cakephp smtp gmail cakephp-2.0


【解决方案1】:

您必须在代码中使用 SSL 选项。

/* SMTP Options */
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'host' => 'ssl://smtp.gmail.com',
'username'=>'your_username@gmail.com',
'password'=>'your_gmail_password',
);

/* Set delivery method */
$this->Email->delivery = 'smtp';

【讨论】:

    猜你喜欢
    • 2012-03-09
    • 2011-05-24
    • 1970-01-01
    • 2014-06-23
    • 2014-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-05
    相关资源
    最近更新 更多