我正在尝试使用 CakePhp 2.0 发送电子邮件。在我的 Controller 中,我使用此代码(我知道它很好,我从 the cookbook 获取它):
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail("myConfig");
$email->from(array('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7315011c1e33160b121e031f165d101c1e" rel="noreferrer noopener nofollow">[email protected]</a>' => 'From Example'));
$email->to($to);
$email->subject($msgtitle);
$ok = $email->send($content);
在app/config/email.php
中我有这个配置:
<?php
class EmailConfig {
public $myConfig = array(
'host' => 'mail.myServer.com',
'port' => 587,
'username' => 'mYaccount',
'password' => 'secret',
'transport' => 'Smtp'
);
}
?>
问题是服务器回答:
SMTP Error: 530 5.7.0 Must issue a STARTTLS command first.
帐户名正确,密码正确。该配置在 Thunderbird 中加载时有效,与 smtp 服务器的连接设置为:
服务器名称:mail.myServer.com
端口:587
连接安全:STARTTLS
身份验证:普通密码
用户名:mYaccount
最佳答案
您确定您的 SMTP 支持 tls 吗?尝试发送 ehlo 命令:
telnet 1.2.3.4 25
ehlo testing
您应该看到类似以下内容:
250-STARTTLS
在列表中。
如果您看到它,则它很可能未启用。您需要启用它。如果您没有看到它,则需要添加它。
关于php - cakephp 2.0 smtp 电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9341787/