Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29758

Could email be sent but still throws an exception?

$
0
0

So I am want to send an email and record in the database that it was sent successfully, here is what I do:

  • First, try sending an email to the user containing the product information

  • Second, check if the email was sent successfully. If yes, then record in the database that it was sent successfully.

But if sending the email failed (an exception was thrown) I want to catch that exception and return an error message.

My question is: Is there a case that the email gets sent but still throws an exception?

So by that the code returns error thinking that the email wasn't sent .. but it was actually sent and the exception was throw later after that.

    // pseudo code      
    try{
        $is_sent = send_email();
        if($is_sent){
            $db->email_was_sent();
        }
    }catch(Exception $e){
        return 'Email was not sent. An exception';
    }

Viewing all articles
Browse latest Browse all 29758

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>