2016-10-31 09:57
浏览 161

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

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

My email Controller is :

public function send() { 
     $from = ""; 
     $to = $this->input->post('email'); 

     $ci = get_instance();
        $config['protocol'] = "smtp";
        $config['smtp_host'] = "ssl://";
        $config['smtp_port'] = "465";
        $config['smtp_user'] = ""; 
        $config['smtp_pass'] = "Mypwd";
        $config['mailpath'] = "/usr/sbin/sendmail";
        $config['mailtype'] = "text";
        $config['newline'] = "


     $this->email->from($from, 'Your Name'); 
     $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.";

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


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 10: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.

    解决 无用
    打赏 举报