2

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)

user3813156
  • 43
  • 1
  • 10

1 Answers1

2

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

Community
  • 1
  • 1
Steve
  • 808
  • 1
  • 9
  • 14
  • Chapter and verse on emailing from scripts: http://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-e-mail – Steve Nov 27 '15 at 04:26