通过smtp使用cakephp发送电子邮件
我有一个发送基本电子邮件的代码。但对于smtp,我无法完善这一点:通过smtp使用cakephp发送电子邮件,php,email,cakephp,sendmail,Php,Email,Cakephp,Sendmail,我有一个发送基本电子邮件的代码。但对于smtp,我无法完善这一点: function send(){ $this->Email->smtpOptions = array( 'port'=>'465', 'timeout'=>'30', 'host' => 'ssl://smtp.gmail.com',
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);
}
}
}
函数send(){
$this->Email->smtpOptions=array(
“端口”=>“465”,
“超时”=>“30”,
'主机'=>'ssl://smtp.gmail.com',
'用户名'=>'csorila@gmail.com',
“密码”=>“我的密码”,
);
$this->Email->delivery='smtp';
$this->Email->send='debug';
$this->Email->to=csorila17@gmail.com';
$this->Email->subject='hurrah';
//$this->Email->replyTo='snoreply@example.com';
$this->Email->from='Charmaine-Khay-Sorila';
//$this->Email->send('这是Email Chams电子邮件测试的主体');
//在发送邮件时设置邮件正文。
//注意:文本可以是一个数组,每个元素将显示为一个数组
//消息正文中的分隔行。
如果($this->Email->send()){
$this->Session->setFlash(“发送简单电子邮件”);
}否则{
$this->Session->setFlash(“未发送简单电子邮件”);
$this->set('smtp_errors',$this->Email->smtpError);
}
}
}
我在没有$this->Email->delivery='smtp'的情况下完成了这项工作;,但当我添加这一行时,根本无法发送电子邮件:(如果您不想实际发送电子邮件,而是想测试功能,可以使用以下交付选项:
Copy to Clipboard
$this->Email->delivery = 'debug';
如果您正在使用调试选项,请尝试删除它的相同内容yossi..实际发生的情况是页面加载数秒后,它将不会发送任何电子邮件..(第一:错误是什么?)你明白了吗?当它没有发送时,如果调试模式设置为2,它不会显示任何错误。那里。我让它工作了,但问题是..我检查了它是否真的是用于发送邮件的smtp,所以我故意输入了错误的密码,但它仍然发送了一封电子邮件…>。