doudou8081 2016-10-31 01:57
浏览 173
已采纳

在Codeigniter无法发送电子邮件 - fsockopen():无法连接到ssl://smtp.gmail.com:465(连接被拒绝)

etting fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused) while sending email.

My email Controller is :

public function send() { 
     $from = "abc@gmail.com"; 
     $to = $this->input->post('email'); 
     date_default_timezone_set("Asia/Kolkata");

     $ci = get_instance();
        $ci->load->library('email');
        $config['protocol'] = "smtp";
        $config['smtp_host'] = "ssl://smtp.gmail.com";
        $config['smtp_port'] = "465";
        $config['smtp_user'] = "abc@gmail.com"; 
        $config['smtp_pass'] = "Mypwd";
        $config['mailpath'] = "/usr/sbin/sendmail";
        $config['mailtype'] = "text";
        $config['newline'] = "
";

        $ci->email->initialize($config);

     $this->email->from($from, 'Your Name'); 
     $this->email->to($to);
     $this->email->subject('Email Test'); 
     $this->email->message('Testing the email class.'); 

     //Send mail 
     if($this->email->send()) {

     $this->load->view('pages/successfully'); }
     else {

    echo "Error in sending Email.";
      show_error($this->email->print_debugger());
     }
  } 

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/simt/public_html/system/core/Exceptions.php:272)

Filename: core/Common.php

Line Number: 568

Backtrace:

File: /home/simt/public_html/application/controllers/Email.php Line: 46 Function: show_error

File: /home/simt/public_html/index.php Line: 315 Function: require_once

展开全部

  • 写回答

1条回答 默认 最新

  • dpd66100 2016-10-31 02:33
    关注

    Connection refused means exactly that the connection to the peer was refused. This is because the server either does not expect connections at the port or because a firewall is blocking the connection. It is probably the last one in your case so check for firewalls which might block the access on the local machine but also in the network. It might also that a firewall in front of the server or the server itself is blocking access for example if your system is on some blacklist known for sending spam.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部