我想用CakePhp 2.0发送电子邮件。在我的控制器我用这个代码(我知道这是很好,我把它从the cookbook):cakephp 2.0 smtp电子邮件
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail("myConfig");
$email->from(array('[email protected]' => '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.
帐户名称正确,密码也正确。在雷鸟装起来的时候,这个配置工作,SMTP服务器的连接设置为:
服务器名称:mail.myServer.com
端口:587
连接安全:STARTTLS
认证:普通口令
用户名:我的帐户
如果你想看到发送SMTP命令一些CakePHP的代码,请上网:http://stackoverflow.com/questions/5294751/using-gmails-outgoing-smtp-from-php -using-tls – 2013-01-18 19:51:49