Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The CI Email send() function only returns true or false. Is there a way to get a more detailed reason as to why a sending failed? I'm using SMTP.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
852 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can further inspect what happened by using the email debugger:

$r = $this->send(FALSE);
if (!$r)
  $this->email->print_debugger()
  ;

From the Codeigniter Email Class Reference.

If you need the debugger output as a string, you can just catch the output with an output buffer:

$errors = array();
... # Loop
$r = $this->send(FALSE);
if (!$r) {
  ob_start();
  $this->email->print_debugger();
  $error = ob_end_clean();
  $errors[] = $error;
}
... # Loop end

Codeigniter in more recent versions requires an explicit FALSE for the $auto_clear parameter of the email->send() function in order to not clear the message and the debugging, effectively killing the debugger function if you fail to pass the FALSE.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...