douzhuiqing1151 2013-12-18 00:20
浏览 113
已采纳

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

I have set the codeIgniter email() to send email from my Google Account, but it errors. 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:

extension=php_sockets.dll
extension=php_openssl.dll

Here is my CI configurations:

$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("
");
        $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. 
  • 写回答

1条回答 默认 最新

  • dongqiao5573 2013-12-18 00:27
    关注

    What version of CI are you using? If it's 2.1.4 then there is a discrepancy in your config array. Try this:

    $configs = array(
        'protocol'  =>  'smtp',
        'smtp_host' =>  'ssl://smtp.gmail.com',
        'smtp_user' =>  'cgmaster.iran@gmail.com',
        'smtp_pass' =>  'PASSWORD',
        'smtp_port' =>  '465'
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效