I try to send an email by codeIgniter

0

I am trying to send an email using the codeigniter framework but I receive the following error.

  

A PHP Error was encountered Severity: Warning Message: fsockopen ():   unable to connect to localhost: 25 (Connection refused) Filename:   libraries / Email.php Line Number: 2061

     

Backtrace:

     

File: /var/www/html/test/application/controllers/Mantencion.php Line:   69 Function: send   File: /var/www/html/test/index.php Line: 315 Function: require_once

Here is my code.

$config = array();
            $config['useragent']           = "CodeIgniter";
            $config['mailpath']            = "/usr/sbin/sendmail"; // or "/usr/sbin/sendmail"
            $config['protocol']            = "smtp";
            $config['smtp_host']           = "localhost";
            $config['smtp_port']           = "25";
            $config['mailtype'] = 'html';
            $config['charset']  = 'utf-8';
            $config['newline']  = "\r\n";
            $config['wordwrap'] = TRUE;

            $this->load->library('email');

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

            $this->email->from('[email protected]', 'admin');
            $this->email->to('[email protected]');

            $this->email->subject('Тест Email');
            $this->email->message('ASDADS');
            // $this->email->message($this->load->view('email/'.$type.'-html', $data, TRUE));

            if ($this->email->send()) {
            $this->session->set_flashdata('success_msg', '  Correo enviado exitosamente');
            }
            show_error($this->email->print_debugger());

I'm using Linux Mint. A query should I install a service to send an email?

    
asked by MoteCL 07.06.2018 в 23:56
source

1 answer

0

You must have a mail server installed or use an external server (mailgun for example). The message tells you that you can not connect to SMTP through port 25 (it is not open).

    
answered by 08.06.2018 в 01:23