CodeIgniter Forums

Full Version: email not sending
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
public function index()
{
//$this->load->view('welcome_message');
$config = Array(
'protocol'=> 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '********@gmail.com',
'smtp_pass' => '********'
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from('*******@gmail.com','kvr');
$this->email->to('******@gmail.com');
$this->email->subject('test mail');
$this->email->message('working');

$path = $this->config->item('server_root');
//echo $path;
//die();

if($this->email->send())
{
echo 'mail sent';
}
else
{
show_error($this->email->print_debugger());
}
}


I got error
*********

1,Message: fsockopen(): SSL: Handshake timed out
2,Message: fsockopen(): Failed to enable crypto
3,Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Unknown error)
4, 
The following SMTP error was encountered: 110 Connection timed out

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

guys help me to solve my problem 
This is wrong.

PHP Code:
$this->load->library('email',$config); 

Should be some thing like this

PHP Code:
$this->load->library('email');

// see the User's Guide for setting these.
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

$this->email->initialize($config); 
(08-04-2018, 02:58 AM)InsiteFX Wrote: [ -> ]This is wrong.

PHP Code:
$this->load->library('email',$config); 

Should be some thing like this

PHP Code:
$this->load->library('email');

// see the User's Guide for setting these.
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

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

An Error Was Encountered

Exit status code: 1
Unable to open a socket to Sendmail. Please check settings.
Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.


public function index()

{

//$this->load->view('welcome_message');

/*$config = array(

'protocol'=> 'smtp',

'smtp_host' => 'ssl://smtp.googlemail.com',

'smtp_port' => 465,

'driver' => 'sendmail',

'smtp_user' => '***@gmail.com',

'smtp_pass' => '*****'

);*/



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

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

$config['protocol'] = 'sendmail';

$config['mailpath'] = '/usr/sbin/sendmail';

$config['charset'] = 'iso-8859-1';

$config['wordwrap'] = TRUE;



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



$this->email->set_newline("\r\n");

$this->email->from('*****@gmail.com','kvr');

$this->email->to('****@gmail.com');

$this->email->subject('test mail');

$this->email->message('working');



$path = $this->config->item('server_root');

//echo $path;

//die();



if($this->email->send())

{

echo 'mail sent';

}

else

{

show_error($this->email->print_debugger());
}
(08-03-2018, 11:31 PM)kvanaraj Wrote: [ -> ]public function index()
{
//$this->load->view('welcome_message');
$config = Array(
'protocol'=> 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '********@gmail.com',
'smtp_pass' => '********'
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from('*******@gmail.com','kvr');
$this->email->to('******@gmail.com');
$this->email->subject('test mail');
$this->email->message('working');

$path = $this->config->item('server_root');
//echo $path;
//die();

if($this->email->send())
{
echo 'mail sent';
}
else
{
show_error($this->email->print_debugger());
}
}


I got error
*********

1,Message: fsockopen(): SSL: Handshake timed out
2,Message: fsockopen(): Failed to enable crypto
3,Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Unknown error)
4, 
The following SMTP error was encountered: 110 Connection timed out

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

guys help me to solve my problem 
You config is a little bit wrong:
ssl://smtp.googlemail.com to smtp.googlemail.com
Add 'smtp_crypto' => 'ssl' to the config array
(08-04-2018, 10:56 PM)Paradinight Wrote: [ -> ]
(08-03-2018, 11:31 PM)kvanaraj Wrote: [ -> ]public function index()
{
//$this->load->view('welcome_message');
$config = Array(
'protocol'=> 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '********@gmail.com',
'smtp_pass' => '********'
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from('*******@gmail.com','kvr');
$this->email->to('******@gmail.com');
$this->email->subject('test mail');
$this->email->message('working');

$path = $this->config->item('server_root');
//echo $path;
//die();

if($this->email->send())
{
echo 'mail sent';
}
else
{
show_error($this->email->print_debugger());
}
}


I got error
*********

1,Message: fsockopen(): SSL: Handshake timed out
2,Message: fsockopen(): Failed to enable crypto
3,Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Unknown error)
4, 
The following SMTP error was encountered: 110 Connection timed out

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

guys help me to solve my problem 
You config is a little bit wrong:
ssl://smtp.googlemail.com to smtp.googlemail.com
Add 'smtp_crypto' => 'ssl' to the config array

Finally i got solution. my network block this . in my home it's working well. how to unblock from network
You would need to edit your network config to allow that port number through it.

It depends on the network your running of which file to edit.