我收到了一份用于发送基本电子邮件的代码。但是对于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-&gt;电子邮件 - &gt; delivery ='smtp';,但是当我添加该行时,根本不会发送任何电子邮件:(
答案 0 :(得分:0)
如果您不想实际发送电子邮件而是想测试其功能,可以使用以下投放选项:
Copy to Clipboard
$this->Email->delivery = 'debug';