4

我收到错误 Fatal error: Uncaught exception 'phpmailerException' with message 'Invalid address: ' etc. etc. etc. 页面上真的很疼。

所以我想捕获错误或抑制它或其他东西 - 然后将其返回到表单中,以便可以告诉用户有错误并重新输入他们的电子邮件地址。所有这些都将是整洁的,而不是现在的错误混乱。

有谁知道如何做到这一点?

谢谢

4

1 回答 1

4
try {
    // your code which sends the email
} catch (phpmailerException $exception) {
    // process the exception here
    // or leave this block blank to just suppress it(which is a bad idea)
}

另请参阅异常手册页

于 2010-08-17T21:53:31.913 回答