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
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.
-
2+1. But please refrain from adding needless footer text to all your answers - ref ("along with other extraneous clutter").– AD7sixCommented 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.– liyakatCommented Jul 8, 2013 at 8:16
-
-
1As 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.– floriankCommented Jul 8, 2013 at 10:39
-