开发者

Capture PHP Errors from SMTP

开发者 https://www.devze.com 2023-03-05 20:56 出处:网络
I have the fo开发者_如何学Cllowing code: if($result = $this->Email->peopleFollowingEmail($follow[\'User\'][\'email\'], $viewer[\'User\'][\'fname\'].\' \'.$viewer[\'User\'][\'lname\'], $viewer[\

I have the fo开发者_如何学Cllowing code:

if($result = $this->Email->peopleFollowingEmail($follow['User']['email'], $viewer['User']['fname'].' '.$viewer['User']['lname'], $viewer['User']['username']))
{
    $pf_model->id = $id;
    $pf_model->saveField('sent_email', 1);
}
else
{
    $pf_model->id = $id;
    $pf_model->saveField('email_error', $result);
}

The Email function either will return true or return $errMessage.

How do I store the error message in my db? I think my $result = ... is wrong.


Try,

$result = $this->Email->peopleFollowingEmail($follow['User']['email'], $viewer['User']['fname'].' '.$viewer['User']['lname'], $viewer['User']['username']);
if($result === true)
{
    $pf_model->id = $id;
    $pf_model->saveField('sent_email', 1);
}
else
{
    $pf_model->id = $id;
    $pf_model->saveField('email_error', $result);
}


If it returns error message and it's a string you are doing it right. If its not a string you need to serialize it before passing it to database using serialize($result) and unserialize($value) when you want to read it back.

0

精彩评论

暂无评论...
验证码 换一张
取 消