Codeigniter 2.1.3的SMTP Gmail错误 [英] SMTP Gmail error with Codeigniter 2.1.3

查看:133
本文介绍了Codeigniter 2.1.3的SMTP Gmail错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到很多帖子与这个问题相关,我已经做了指令,但总是得到相同的错误..

i have seen many post related to this problems, i have done the instruction given but always get the same error..

我想使用代码发送smtp gmail Igniter 2.1.3,这是代码:

I want to send smtp gmail using Code Igniter 2.1.3, this is the code :

class Email extends CI_Controller{

function index(){

$config = Array(
'protocol'      => 'smtp',
'smtp_crypto'   => 'ssl',
'smtp_host'     => 'smtp.gmail.com',
'smtp_user'     => 'myEmail@gmail.com',
'smtp_pass'     => '***********',
'smtp_port'     => 25,
'mailtype'      => 'text',
'smtp_timeout'  =>  15, 
'charset'       => 'iso-8859-1'
);
$this->load->library('email', $config);

$this->email->set_crlf("\r\n");
$this->email->set_newline("\r\n");
$this->email->from("myEmail@gmail.com", "myName");
$this->email->to("myEmail@gmail.com");
$this->email->subject("Email Test");
$this->email->message("This is email test");

if($this->email->send()){
    echo 'Email Send';
    }   else{
        show_error($this->email->print_debugger());
    }
}

并且错误总是这样,

Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:25 (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. )

请帮助我修复此错误,谢谢:)

Please help me fixing this error, thanks :)

推荐答案

您需要在php.ini文件中启用您的ssl服务器配置,如果使用Xampp服务器,您可以检查它是否已启用。在那里去PHP信息搜索ssl .........

You need to enable your ssl in php.ini file in your server configuration and you can check whether it is enabled or not if you are using Xampp server. In that go to PHP info search for ssl.........

你需要删除; before extension = php_openssl.dll php.ini文件中的此行。

You need to remove ; before extension=php_openssl.dll this line in php.ini file.

您需要启用OpenSSL ........

You need to enable OpenSSL........

我最近遇到这个错误。您的代码中有一个小错误........

I faced this error recently.There is a small mistake in your code........

function sendMail()
{
    $config = Array(
  'protocol' => 'smtp',
  'smtp_host' => 'ssl://smtp.googlemail.com',
  'smtp_port' => 465,
  'smtp_user' => 'xxx@gmail.com', // change it to yours
  'smtp_pass' => 'xxx', // change it to yours
  'mailtype' => 'html',
  'charset' => 'iso-8859-1',
  'wordwrap' => TRUE
);

        $message = $this->load->view('upload_success','',TRUE);
        $this->load->library('email', $config);
      $this->email->set_newline("\r\n");
      $this->email->from('xxx@gmail.com'); // change it to yours
      $this->email->to('yyy@gmail.com');// change it to yours
      $this->email->subject('Resume from JobsBuddy for your Job posting');
      $this->email->message($message);
      if($this->email->send())
     {
      echo 'Email sent.';
     }
     else
    {
     show_error($this->email->print_debugger());
    }

}

我使用后,我解决了面对的问题.....

This is a working code which i am using after i solved the problem which u r facing.....

这篇关于Codeigniter 2.1.3的SMTP Gmail错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆