How to resolve the error: Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
Use Tls istead of ssl and change port number to 587 $this->email->initialize($config); $config = array();
//Load email library
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'tls://smtp.gmail.com';
$config['smtp_port'] = '587';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'email';
$config['smtp_pass'] = 'password';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$config['validation'] = TRUE; // bool whether to validate email or not
$this->email->set_newline("\r\n");
;
$this->email->clear(TRUE);
$this->email->to($this->input->post('email'));
$this->email->subject($row_email->email_subject);
Abhijit Kumbhar
Updated on October 02, 2020Comments
-
Abhijit Kumbhar over 3 years
I'm using codeigniter I created one email function to send email to particular email ID
public function email($email){ $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.gmail.com'; $config['smtp_timeout']=5; $config['smtp_port'] = '465'; $config['smtp_user'] = '[email protected]'; $config['smtp_pass'] = '********************'; $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]', 'MyEmailID'); $this->email->to($email); $this->email->subject('My Subject'); $this->email->message('My Message'); return $this->email->send(); }
That's working nice in my local machine but when I uploaded that code to hosting server (I'm using Godaddy hosting) I'm getting following error:
A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
Filename: libraries/Email.php
Line Number: 2020
Backtrace:
File: /home/MyDir/public_html/application/models/BasicModel.php Line: 47 Function: send
File: /home/MyDir/public_html/application/controllers/Login.php Line: 48 Function: email
File: /home/MyDir/public_html/index.php Line: 315 Function: require_once
-
Abhijit Kumbhar over 7 yearsThat's not the mistake in my code I did that accidentally while typing question ..
-
Abhijit Kumbhar over 7 yearsI'm using godaddy host so where shoud I found php.ini
-
dhruv jadia over 7 yearshave you chacked with first solution?
-
dhruv jadia over 7 yearsreference how to create php.ini on godaddy server stackoverflow.com/questions/16140917/…
-
Abhijit Kumbhar over 7 yearsLet us continue this discussion in chat.