Why do some email servers not send back a 'could not be delivered' email when the recipient does not exist?
Some email servers do not send back a 'could not be delivered' email when the recipient does not exist in order to prevent email harvesting and spamming. To solve this issue, you can implement email verification before sending the email to ensure that the recipient's email address is valid.
// Check if recipient email address is valid before sending email
$recipient_email = 'recipient@example.com';
if (filter_var($recipient_email, FILTER_VALIDATE_EMAIL)) {
// Send email
mail($recipient_email, 'Subject', 'Message');
} else {
echo 'Invalid email address';
}
Related Questions
- What are some best practices for managing aliases for class names in PHP, especially in larger applications?
- What are the potential pitfalls when using regular expressions in PHP for string manipulation?
- What are the potential pitfalls of using str_replace() in PHP for replacing placeholders in text retrieved from a database?