Docker Community Forums

Share and learn in the Docker community.

Container in laradock not sending emails

docker

(Memowii) #1

I’m using laradock with two containers, apache2 and mysql. I copied and pasted my codeigniter project that I had in a virtual machine, my problem happens when I want to send an email using codeigniter’s Email class.

This is my function:

public function send_email($from_email, $from_name, $reply_to_email, $reply_to_name, $to_email, $subject, $message)
{
    $this->load->library('email');
    $this->email->from($from_email, $from_name);
    $this->email->reply_to($reply_to_email, $reply_to_name);
    $this->email->to($to_email);
    $this->email->subject($subject);
    $this->email->message($message);
    $this->email->send();
}

This is how I used that function:

$this->send_email('emaili@hotmail.com', 'memo wii', 'email@hotmail.com',
    'memo wii', 'email2@gmail.com', 'prueba', 'hola memogl');

I'm always getting these errors:

A PHP Error was encountered

Severity: Warning

Message: fsockopen(): unable to connect to webmail.restodata.net:25 (No route to host)

Filename: libraries/Email.php

This is another error:

A PHP Error was encountered

Severity: Warning

Message: fwrite() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1847

Any idea about how to solve it?

Notes:

  • I’m using codeigniter 2
  • My docker version is Docker version 18.03.1-ce, build 9ee9f40
  • I use docker-compose up --build apache2 mysql to run my containers