Friday 15 February 2013

CakePHP Email Component check if email was sent -


I'm thinking how you can verify that email has been sent or while using e-mail content in kppp Has this been unsuccessful?

For example, I am currently using it this way:

  $ this-> Email-> From = '& lt; Xyz@yahoo.com> '; $ This- & gt; Email-> = 'To & lt; Abc@gmail.com> '; $ This- & gt; Email-> SendAs = 'Both'; $ This- & gt; Email-> Delivery = 'debug'; $ This- & gt; Email-> Send ();    

$ this-> Email-> Send () should if it was sent successfully, it will be true. You can try doing something like this:

  If ($ this-> Send email-> ()) {// Success} and {// Failure}   

reference:

Note: If you are using KPPP 2.x, you try to use the Kakemail class instead can do; EmailComponent is deprecated () If you are using 1.x, then proceed. : P

Edit:

As mentioned in the comments, if you are using 2.x You should keep in mind that cake email (which is used by email companion) can throw an exception. You can handle it or throw it in an attempt / grip:

  try {if (> $-> Email- & gt; Send ()) {// Success } Else {// failure, without exception}} (exception $ E) {// failure, with exception}    

No comments:

Post a Comment