5
如何檢查在CakePHP中發送電子郵件是否成功?檢查發送郵件是否成功/不成功在CakePHP中?
我可以發送電子郵件沒有問題,但我希望能夠處理錯誤,如果它發送失敗。我怎樣才能做到這一點?
這是我迄今所做的:
$email = new CakeEmail();
$email->from(array('email' => 'title'));
$email->to($to);
$email->subject('Account activation');
$activate_url = 'http://' . env('SERVER_NAME') .'/cakephp/users/activate/'.$id.'/'.$token;
$message = "Thank you for signing up. Click on the activation link to activate your account \n";
return $email->send($message.$activate_url);
您是否使用了try catch? – 2013-04-10 16:58:23
充其量你可以檢測到郵件是否已交給smtp服務器正確。您不能直接檢測接收服務器是否拒絕/發送垃圾郵件,或者您的smtp服務器是否延遲/排隊郵件。 – 2013-04-10 16:58:37