PHP mail not working for some reason
If you are using Ubuntu and it seem sendmail is not in /usr/sbin/sendmail
, install sendmail using the terminal with this command:
sudo apt-get install sendmail
and then run reload the PHP page where mail()
is written. Also check your spam folder.
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.
This might be the issue of your SMTP config in your php.ini file.
Since you new to PHP, You can find php.ini file in your root directory of PHP installation folder and check for SMTP = and smtp_port= and change the value to
SMTP = your mail server e.g) mail.yourdomain.com
smtp_port = 25(check your admin for original port)
In case your server require authentication for sending mail, use PEAR mail function.
"Just because you send an email doesn't mean it will arrive."
Sending mail is Serious Business - e.g. the domain you're using as your "From:" address may be configured to reject e-mails from your webserver. For a longer overview (and some tips what to check), see http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html
The mail function do not guarantee the actual delivery of mail. All it do is to pass the message to external program (usually sendmail). You need a properly configured SMTP server in order for this to work. Also keep in mind it does not support SMTP authentication. You may check out the PEAR::Mail library of SwiftMailer, both of them give you more options.