0

In my CakePHP web application I'm sending mails and if mail is successfully sent then updating data base field 'mailSent' to true. But How to know that mail is successfully sent or not?

1 Answer 1

1

You can use a try catch block to check whether the mail was successfully send or not, you can not detect or check if the mail was successfully delivered to the recipient. That is a different scenario.

try {
    if ( $this->Email->send() ) {
        // Success
    } else {
        // Failure, without any exceptions
    }
} catch ( Exception $e ) {
    // Failure, with exception
}

above is just sudo code you can change variable as you need.

let me know if i can help you more.

6
  • 2
    +1. But please refrain from adding needless footer text to all your answers - ref ("along with other extraneous clutter").
    – AD7six
    Commented Jul 8, 2013 at 7:40
  • @AD7six, thanks, but that would be good to not hesitate to ask if my answer will not helpful to person. and i will try to not add my self to my answer, Thanks a lot again.
    – liyakat
    Commented Jul 8, 2013 at 8:16
  • @AD7six, ohh ok boss i will do :(
    – liyakat
    Commented Jul 8, 2013 at 8:33
  • 1
    As an addition to this answer you should be aware that even if send() returns true it does not mean that that the email was really going out. There is not always a way for php to be sure the email was send (or received) successfully. For example the mail server could have a problem.
    – floriank
    Commented Jul 8, 2013 at 10:39
  • @burzum yes i am agree with you :)
    – liyakat
    Commented Jul 8, 2013 at 11:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.