0
votes

i am trying to send email using codeigniter email class but i am getting error Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection timed out)

public function index()
     {
     $this->load->helper('form');
    $this->load->view('sellerend/seller_signup.php');
       $config = array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.gmail.com',
        'smtp_port' => '465',
        'smtp_user' => '[email protected]',
        'smtp_pass' => 'mypassword',
        'mailtype'  => 'html', 
        'charset'   => 'iso-8859-1'
        );

    $this->load->library('email',$config);
    $this->email->initialize($config);
    $this->email->set_newline("\r\n");
    $this->email->from('[email protected]','my name');
    $this->email->to('[email protected]');
    $this->email->message('its working bro');
    if ($this->email->send())
    {
        echo "hi its works";
    }
    else
    {
        show_error($this->email->print_debugger());
    }
}
2

2 Answers

1
votes

Go to your gmail account and allow less secure apps under connected apps and sites

Change

 $this->load->library('email',$config)
 $this->email->initialize($config);

to

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

and

 'charset'   => 'iso-8859-1'

to

 'charset'   => 'utf-8'
0
votes

Use PHP Mailer and go to your Gmail account and allow the less secure app Example See Here