PHP mail stopped working
Could it be that E-Mails are being sent fine, but are caught by a spam filter?
If this could be, allow me to cross-post myself:
A few bullet points (Assuming that mail() returns true and there are no errors in the error log) :
- Does the sender address ("From") belong to a domain on your server? If not, make it so.
- Is your server on a blacklist (e.g. check IP on spamhaus.org)? This is a remote possibility with shared hosting.
- Are mails filtered by a spam filter? Open an account with a freemailer that has a spam folder and find out. Also, try sending mail to an address without a spam filter.
- Do you possibly need the fifth parameter "-f" of mail() to add a sender address? (See mail() command in the PHP manual)
- If you have access to log files, check those, of course, as suggested above.
- Do you check the "from:" address for possible bounce mails ("Returned to sender")? You can also set up a separate "errors-to" address.
For german speakers, I have written a quite exhaustive "what to do" on this issue some time ago. See here.
PHP mail not working for some reason
This is probably a configuration error. If you insist on using PHP mail
function, you will have to edit php.ini
.
If you are looking for an easier and more versatile option (in my opinion), you should use PHPMailer.
PHP Mail Not Sending But No Errors
Try this to find out where is the problem
$success = mail('example@example.com','New Enquiry',$msg);
if (!$success) {
print_r(error_get_last()['message']);
}
with a glance at Php Mail Documentation
Note:
When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.
Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.Return Values
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.
update
After comments just for test, remove every code in your php file an just try the simplest way to debug
<?php
// the message
$msg = "First line of text\nSecond line of text";
// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);
// send email
if(!mail("someone@example.com","My subject",$msg)){
var_dump(error_get_last()['message']);
}
?>
PHP Mail just suddenly stop working
Alright, the issue here is that mail exim of the hosting server was broken. So, hosting support had to update it and that fixes the problem.
PHP mail() function has stopped working
Basically sorted it. Started trying to use PEAR and the Mail plugin, but found it horrible. Ended up using an external SMTP server and PHPMailer, much better.
Useful Info: http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html https://orangsetya.wordpress.com/2007/09/12/send-mail-using-smtp-authentication-phpmailer-script
Cheers.
PHP mail function is not working on the server
It returns FALSE
, it means there is a problem with your mail configuration. You would need to check the mail log to see if you are getting any errors. The kicker is that php may be handing off the mail, your server may be sending off the mail, and it may get spam filtered along the way.
<?php
mail('nobody@example.com', 'the subject', 'the message', null, '-fwebmaster@example.com');
?>
Related Topics
Mysqli + Xdebug Breakpoint After Closing Statement Result in Many Warnings
How to Pass Value from One PHP Page to Another Using Session
Decrypting Strings in Python That Were Encrypted with Mcrypt_Rijndael_256 in PHP
PHP Warning: Exec() Unable to Fork
How to Pass Multiple Variables Across Multiple Pages
Simplexml Get Attributes with a Namespace
In PHP What Does It Mean by a Function Being Binary-Safe
How to Do Single Sign-On with PHP
Facebook Error 'Error Validating Verification Code'
How to Create Custom Seo-Friendly Urls in Opencart
Point in Polygon Algorithm Giving Wrong Results Sometimes