我正在制作一个用于收集用户数据的系统。我知道有些会是垃圾邮件!我只想知道如果电子邮件不正确,邮件函数是否返回 false?
说我有。
<?php
$to = "fake@fake.com";
$header = "From: {$to}";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body, $header)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
如果电子邮件不正确,将打印哪条消息?
如果它确实返回 false,我希望在该数据库中存储一个“标志”,以便管理员可以查看并删除它。
最佳答案
不一定。
根据 manual , mail()
如果消息被接受传递,函数将返回 true
- 但不保证它会被传递:
Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.
It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.
关于php - 如果电子邮件不正确,PHP 邮件函数是否返回 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11971014/