我有这个配置:
class EmailConfig {
public $default = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'myemail@gmail.com',
'password' => 'mypassword');
}
编码:
$Email = new CakeEmail('default');
$Email->viewVars(array('first_name' => $user['User']['first_name'], 'link' => $link, 'last_name' => $user['User']['last_name'], 'otp' => $otp, 'html_link' => $html_link));
$Email->to($username);
$Email->emailFormat('both');
$Email->from('myemail@gmail.com');
$Email->subject("Course Registration");
$Email->template('welcome');
$Email->send();
这在我的Mac上工作得很好,没有问题,但在我的同事的Windows框中,他得到了这个错误: 无法发送电子邮件
有人可以解释原因吗?
Request URL: /Users/activate/165
Stack Trace:
#0 C:\wamp\www\cakephp\lib\Cake\Network\Email\MailTransport.php(47): MailTransport->_mail('pradhan.sabin@g...', 'Course Registra...', '--20cbbe22cace5...', 'From: mmassites...', NULL)
#1 C:\wamp\www\cakephp\lib\Cake\Network\Email\CakeEmail.php(1066): MailTransport->send(Object(CakeEmail))
#2 C:\wamp\www\cakephp\app\Controller\UsersController.php(727): CakeEmail->send()
#3 C:\wamp\www\cakephp\app\Controller\UsersController.php(665): UsersController->otpactivation('165')
#4 [internal function]: UsersController->activate('165')
#5 C:\wamp\www\cakephp\lib\Cake\Controller\Controller.php(486): ReflectionMethod->invokeArgs(Object(UsersController), Array)
#6 C:\wamp\www\cakephp\lib\Cake\Routing\Dispatcher.php(187): Controller->invokeAction(Object(CakeRequest))
#7 C:\wamp\www\cakephp\lib\Cake\Routing\Dispatcher.php(162): Dispatcher->_invoke(Object(UsersController), Object(CakeRequest), Object(CakeResponse))
#8 C:\wamp\www\cakephp\app\webroot\index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#9 {main}
2013-06-07 21:09:31 Error: current url is :/Users/activate/165
答案 0 :(得分:0)
在Windows上有一种方法可以通过编辑你的php.ini来实现:
smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=465
我没有测试过这个,所以我不确定它是否有效。这是一个使用Windows的大学。