为什么gmail smtp在使用localhost在cakephp中发送邮件时不起作用

时间:2014-04-04 08:14:53

标签: email cakephp

我说错了。

Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?

但是我已经在php.ini文件中启用了它

这是我的EmailConfig

public $gmail = array(
            'host' => 'ssl://smtp.gmail.com',
            'port' => 465,
            'username' => 'email@gmail.com',
            'password' => 'password',
            'transport' => 'Smtp',
            'timeout' => 30,
    );

和我的控制器

public function send_mail(){
        $message = 'Test email';
        App::uses('CakeEmail', 'Network/Email');
        $email = new CakeEmail('gmail');
        $email->from('email@gmail.com');
        $email->to('email@yahoo.com');
        $email->subject('Test');
        $email->send($message);
    }

我没有看到问题出在哪里

1 个答案:

答案 0 :(得分:1)

试试这个

public function send_mail(){
        $message = 'Test email';
        App::uses('CakeEmail', 'Network/Email');
        $email = new CakeEmail();
        $email->config('gmail')
             ->from('email@gmail.com')
             ->to('email@yahoo.com')
             ->subject('Test')
             ->send($message);
    }

I Want to send email from cakephp 2.x in company domain email adress

CakePHP send email

下一步

  

来自wamp Apache / Apache_modules / tick ssl_module

最后

  

启用php_openssl和php_opensockets

http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/