【发布时间】:2012-05-03 06:44:48
【问题描述】:
我有一个用于发送基本电子邮件的代码。但对于 smtp,我无法完善:
function send(){
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'host' => 'ssl://smtp.gmail.com',
'username'=>'csorila@gmail.com',
'password'=>'mypassword',
);
$this->Email->delivery='smtp';
$this->Email->send = 'debug';
$this->Email->to = 'csorila17@gmail.com';
$this->Email->subject = 'hurrah';
// $this->Email->replyTo = 'noreply@example.com';
$this->Email->from = 'Charmaine Khay Sorila<noreply@example.com>';
//$this->Email->send('Here is the body of the email Chams Email Test');
//Set the body of the mail as we send it.
//Note: the text can be an array, each element will appear as a
//seperate line in the message body.
if ( $this->Email->send() ) {
$this->Session->setFlash('Simple email sent');
} else {
$this->Session->setFlash('Simple email not sent');
$this->set('smtp_errors', $this->Email->smtpError);
}
}
}
我在没有 $this->Email->delivery='smtp'; 的情况下可以正常工作,但是当我添加该行时,根本无法发送电子邮件:(
【问题讨论】:
-
您正在使用调试选项,请尝试删除它
-
同样的事情 yossi..实际发生的是页面加载了几秒钟,然后它不会发送任何电子邮件... :(
-
第一:你得到的错误是什么?
-
不发送时,只要调试模式设置为2,就不会显示任何错误。
标签: php email cakephp sendmail