PHP 8.5.0 Alpha 4 available for testing

Voting

: max(one, three)?
(Example: nine)

The Note You're Voting On

php at simoneast dot net
8 years ago
Often it's helpful to find the exact error message that is triggered by the mail() function. While the function doesn't provide an error directly, you can use error_get_last() when mail() returns false.

<?php
$success
= mail('[email protected]', 'My Subject', $message);
if (!
$success) {
$errorMessage = error_get_last()['message'];
}
?>

(Tested successfully on Windows which uses SMTP by default, but sendmail on Linux/OSX may not provide the same level of detail.)

Thanks to https://stackoverflow.com/a/20203870/195835

<< Back to user notes page

To Top