简体   繁体   English

电子邮件组件cakephp

[英]email component cakephp

First time using the email component... I followed the book instruction and I set this 第一次使用电子邮件组件...我按照书中的说明进行了设置

function sendNewUserMail($id) {
    $User = $this->User->read(null,$id);
    $this->Email->to = array('MyEmai@gmail.com'); 
    $this->Email->from = 'MyEmai@gmail.com';
    $this->Email->subject = 'Welcome to our really cool thing';
    $this->Email->template = 'simple_message'; 

    $this->Email->sendAs = 'text'; 
    $this->Email->smtpOptions = array(
        'port'=>'465', 
        'timeout'=>'30',
        'auth' => true,
        'host' => 'ssl://smtp.gmail.com',
        'username'=>'MyEmail@gmail.com',
        'password'=>'*********'   
    );
    $this->set('User', $User);
    $this->Email->delivery = 'smtp';
    $this->Email->send();
    $this->set('smtp_errors', $this->Email->smtpError);
 }

I try to run the method, but nothing happens... I created the layouts, the elements, and put var $component = array('Email'); 我尝试运行该方法,但是什么也没有发生……我创建了布局,元素,然后将var $component = array('Email');

I'm getting this error 我收到这个错误

Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?: 16 找不到套接字传输“ ssl”-在配置PHP时是否忘记启用它?:16

by the way I at home so no firewalls, no blocking etc 顺便说一句,我在家里,所以没有防火墙,没有阻塞等

Gmail smtp requires a secure connection and it looks like your PHP configuration doesn't have ssl enabled. Gmail smtp需要安全的连接,并且您的PHP配置似乎未启用ssl。 Open php.ini and look for a line that looks like 打开php.ini并查找看起来像这样的行

;extension=php_openssl.dll

or 要么

#extension=openssl.so

and uncomment it (remove the ; or the #), then restart PHP. 并取消注释(删除;或#),然后重新启动PHP。

If you can't find such line there you may need to install OpenSSL first. 如果找不到此类行,则可能需要先安装OpenSSL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM