I am trying find solution for providing proper message in case of net connection lost or no internet at all, I am using codeigniter to send mail and smpt protocol. This the code i am using
<?php
function sending_mail(){
$mail_config = Array (
'mailtype' =>'html',
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'myemail@gmail.com',
'smtp_pass' => 'mypassword',
'charset' => 'iso-8859-1'
);
$this->load->library('email',$mail_config);
$this->email->set_newline("\r\n");
$this->email->from('myemail@gmail.com', 'InnoLogiq LLP');
$this->email->to('receipientemail@gmail.com');
$message = 'mymessage';
$this->email->subject("mysubject");
$this->email->message($message);
if($this->email->send()){
$data['flag']="success" ;
$data['msg']="Email sent";
$this->load->view('templates/header1');
$this->load->view('company/contact_us',$data);
$this->load->view('templates/footer');
}
else{
$data['msg']="Here I want mesage but its showing error, due to net connection";
$data['flag']='error';
print_r("Sorry! mail not send");
$this->load->view('company/contact_us',$data);
}
}
I tried show_error also tried removing that, but if my connection is slow or it fails to send email or fails to upload attachments then it simply shows dozens of errors I want to get rid of those errors and need to provide proper response to end user. Any suggestion please....