我一直在尝试通过 Gmail 在 xampp 上使用 Pear 发送电子邮件,在花了几个小时进行设置并弄清楚我遇到的所有错误之后,我以为我已经很接近了,直到我开始收到这个错误:控制器操作
public function automail() {
App::uses('CakeEmail', 'Network/Email');
$ret_msg = null;
try {
$is_call_email = true;
$subject = "case detail";
$comment = "Ready to Review";
$email_to = "exmaple@gmail.com";
if ($is_call_email == true) {
$email_to = str_replace(' ', '', $email_to);
$email_addresses = preg_split('/[;,]/', $email_to);
$this->log($is_call_email,'bool');
$email = new CakeEmail();
$email->from(array($this->Session->read('Auth.User.email') => $this->Session->read('Auth.User.name')))
->to($email_addresses)
->subject($subject)
->send($comment);
$this->log($subject,'subject');
}
} catch (Exception $ex) {
$ret_msg = $ex->getMessage();
$this->log($ex->getLine(), 'emailError');
}
$this->log('Return msg is = ' . $ret_msg, 'shared');
return;
在 email.php 中
<?php
class EmailConfig {
public $default = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'example@gmail.com', //example@gmail.com
'password' => 'secret',
'transport' => 'Smtp',
'from' => array('exampe@gmail.com' => 'Nam Email'),
'log' => true
);
}
from 和 to 两者都是相同的电子邮件地址,因为我被发送到我的帐户中进行测试...请帮助我或提供有关如何使用 cakephp 发送电子邮件的任何建议...。