Hardik Sondagar
Hardik Sondagar

Reputation: 4495

How to know CakePHP mail has been sent successfully or not?

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?

Upvotes: 0

Views: 383

Answers (1)

liyakat
liyakat

Reputation: 11853

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.

Upvotes: 1

Related Questions