Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Message:mail()[function.mail]:无法连接到位于“的邮件服务器”;ssl://googlemail.com" 端口465_Php_Codeigniter - Fatal编程技术网

Php Message:mail()[function.mail]:无法连接到位于“的邮件服务器”;ssl://googlemail.com" 端口465

Php Message:mail()[function.mail]:无法连接到位于“的邮件服务器”;ssl://googlemail.com" 端口465,php,codeigniter,Php,Codeigniter,//有人知道我是怎么修好的吗。我已经在php.ini上取消了必要文件的注释,但没有任何效果,我仍然会收到错误,我正在使用xampp作为本地主机 //emails.php 功能电子邮件(){ $this->load->model('user'); $emails=$this->user->get_emails(); $this->load->library('email'); $config['mailtype']='html'; $this->email->initialize($config)

//有人知道我是怎么修好的吗。我已经在php.ini上取消了必要文件的注释,但没有任何效果,我仍然会收到错误,我正在使用xampp作为本地主机

//emails.php
功能电子邮件(){
$this->load->model('user');
$emails=$this->user->get_emails();
$this->load->library('email');
$config['mailtype']='html';
$this->email->initialize($config);
foreach($row形式的电子邮件){
$email\u config=Array(
'协议'=>'smtp',
'smtp_主机'=>'ssl://smtp.googlemail.com',
“smtp_端口”=>“465”,
'smtp_用户'=>'dirk@gmail.com',
“smtp_pass”=>“dirk”,
“邮件类型”=>“html”,
'starttls'=>正确,
“换行符”=>“\r\n”
);
$this->load->library('email',$email\u config);
如果($row['email'])){
$this->email->from($this)dirk@gmail.com","德克",;
$this->email->to($row['email']);
$this->email->subject(“测试时事通讯”);
$this->email->message('您的电子邮件在这里!Bold);
$this->email->send();
$this->email->clear();
}
}
}
//user.php
函数get_emails(){
$this->db->select('email')->from('users');
$query=$this->db->get();
返回$query->result_array();
}

GMail不使用
googlemail.com
进行smtp,smtp服务器是
smtp.GMail.com
希望能有所帮助


您需要
smtp.gmail.com

放置有效的gmail电子邮件,而不是
abc@gmail.com
smtp\u用户处填写密码。同时将有效电子邮件放入
$from
数组和
$to
数组中

  $emailConfig = array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => 'abc@gmail.com',
        'smtp_pass' => '*******',
        'mailtype' => 'html', //text or html
        'charset' => 'iso-8859-1',
    );
     $from = array('email' => 'abc@gmail.com');
    $to = array('abc@gmail.com');
    $subject = "Testing Mail";
    $message = "Welcome";
    $this->load->library('email', $emailConfig);
    $this->email->initialize($emailConfig);

    $this->email->set_newline("\r\n");
    $this->email->from($from['email']);
    $this->email->to($to);
    $this->email->subject($subject);
    $this->email->message($message);

    if ($this->email->send()) {
     echo "success";
          } else {

        show_error($this->email->print_debugger());

    }
}

这里有一个非常类似的问题:@jtheman我已经完成了他们发布的内容,但仍然是相同的错误。那么我应该在哪里配置我的smtp服务器呢?
  $emailConfig = array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => 'abc@gmail.com',
        'smtp_pass' => '*******',
        'mailtype' => 'html', //text or html
        'charset' => 'iso-8859-1',
    );
     $from = array('email' => 'abc@gmail.com');
    $to = array('abc@gmail.com');
    $subject = "Testing Mail";
    $message = "Welcome";
    $this->load->library('email', $emailConfig);
    $this->email->initialize($emailConfig);

    $this->email->set_newline("\r\n");
    $this->email->from($from['email']);
    $this->email->to($to);
    $this->email->subject($subject);
    $this->email->message($message);

    if ($this->email->send()) {
     echo "success";
          } else {

        show_error($this->email->print_debugger());

    }
}