简体   繁体   English

从gmail发送带有CodeIgniter email()库的邮件(在Localhost中)不起作用

[英]Sending mail (in Localhost) with CodeIgniter email() library from gmail does not work

I have set the codeIgniter email() to send email from my Google Account, but it errors. 我已将codeIgniter email()设置为从我的Google帐户发送电子邮件,但发生错误。 It does not work, it says it cannot connect to the server or that the server party does not respond. 它不起作用,表示无法连接到服务器或服务器方未响应。

I have enabled (uncommented) these extensions in php.ini: 我已经在php.ini中启用(未注释)这些扩展:

extension=php_sockets.dll
extension=php_openssl.dll

Here is my CI configurations: 这是我的CI配置:

$configs = array(
        'protocol'=>'smtp',
        'smtp_host'=>'ssl://smtp.gmail.com',
        'smtp_user'=>'cgmaster.iran@gmail.com',
        'smtp_pass'=>"PASSWORD",
        'smtp_port'=>'456'
        );
        $this->load->library("email", $configs);
        $this->email->set_newline("\r\n");
        $this->email->to("mostafatalebi@rocketmail.com");
        $this->email->from("cgmaster.iran@gmail.com", "Mostafa Talebi");
        $this->email->subject("This is bloody amazing.");
        $this->email->message("Body of the Message");
        if($this->email->send())
        {
            echo "Done!";   
        }
        else
        {
            echo $this->email->print_debugger();    
        }

And here is the first line of the Error that I am getting: 这是我得到的错误的第一行:

The following SMTP error was encountered: 10060 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 

What version of CI are you using? 您正在使用什么版本的CI? If it's 2.1.4 then there is a discrepancy in your config array. 如果是2.1.4,则您的配置数组中存在差异。 Try this: 尝试这个:

$configs = array(
    'protocol'  =>  'smtp',
    'smtp_host' =>  'ssl://smtp.gmail.com',
    'smtp_user' =>  'cgmaster.iran@gmail.com',
    'smtp_pass' =>  'PASSWORD',
    'smtp_port' =>  '465'
);

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

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