0
$this->email->to($this->session->userdata('email1'));
$this->email->subject('Hall-book');
$this->email->message(''.$message['uname'].'');
if ($this->email->send()) {
    log_message("info","mail sent");
} else {
    log_message("info","mail not sent");
}

If my email, suppose email1, is wrong email. It should not send the email, else part should be executed, but it's showing the message sent. Please help me for this.

jleft
  • 3,457
  • 1
  • 23
  • 35
  • 1
    Define "wrong e-mail... if you just made a typo like `@gmial.com`, the mail will be sent, I don't think this is a good way to test for error... – Laurent S. Jun 17 '14 at 06:41
  • No,Actually I have sent some thing hjhjhhuhuhj@gmail.com then also its showing "the mail has sent "!! – user2986372 Jun 17 '14 at 07:45

2 Answers2

0

whether you have given a wrong email id or not, it should send the mail with the specified Id. it will not check for a valid email id(it will not ensure succesfull email delivery). So "if($this->email->send())" always return true. thats why, u r getting sent message. I hope u will change your error checking method.

My suggetion,

either add a try catch block to catch the run time error(it won't solve valid email id problem) or do a email validation before send.

SilverShadow
  • 85
  • 1
  • 9
  • Thanks,For correct email id it will send the mail. I think I need to do the verification of that mail id before sending. – user2986372 Jun 17 '14 at 07:47
0

This function is send mail only. when mail is send then $this->mail->send(); return true. For check the email id you should write a different block of code if mail is correct then this function is called otherwise return false.

Pritesh
  • 172
  • 1
  • 14