This question already has an answer here:
-
PHP mail function doesn't complete sending of e-mail
25 answers
I am trying to send a simple email on one of my web pages.
mail('myemail@gmail.com', 'NEW ORDER', 'order details');
The code does not work on my xampp localhost, nor my server. (i received no emails).
I read about having to edit a php.ini file on my server, but it seemed to allow it (based on my minuscule knowledge).
[mail function]
sendmail_path = /usr/local/bin/sendmail -oi -t
Any ideas?
My main goal is to be able to send it on my actual website. (im not as worried about the actual localhost)
You need to ensure that the email "From" address is a valid address which exists on your server - see my answers among others
Authenticate Email PHP
And you need a "From" on your mail();
- which you appear to be missing - see
PHP mail form isn't working
Add a "Reply-To:" header and use the email address which you get from your user in that, so that you receive an email which you can reply to rather than it defaulting to going to your server.
Other useful comments:
PHP mail not working for some reason
My personal favourite solution also recommended by plenty of others: PHPMailer https://github.com/PHPMailer/PHPMailer