skip to Main Content

A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Permission denied)

$config = array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'user',
    'smtp_pass' => 'password',
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("rn");

2

Answers


  1. Try defining your EMAIL_SMTP_HOST to

    define("EMAIL_SMTP_HOST", "ssl://smtp.gmail.com");
    

    If by chance it doesnt work check your EMAIL_SMTP_PORT it may be different to what you set there

    define("EMAIL_SMTP_PORT",225O);
    

    Lastly check if by chance your SSL Certificate is installed in your server,same to the mail server also make sure your cridentials both "SMTP_USERNAME" and "SMTP_PASSWORD" are correct.

    Login or Signup to reply.
  2. If you’re running Red Hat-derivatives, they come with SELinux enabled by default, and probably php-fpm is denied access to create socket. Try checking it by running grep php /var/log/audit/audit.log | grep denied.

    If so, you can run /usr/sbin/setsebool httpd_can_network_connect 1 as root, then try to run the code again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search