-2

I configure my php.ini and sendmail.ini,i wrote a simple code to send mail but i don't receive anything on my mail adresse.

<?php 
mail('hmidi_slim@hotmail.fr','test message','1 2 test');
?>

php.ini:

SMTP = localhost
smtp_port = 25
sendmail_path ="C:\xampp\sendmail\sendmail.exe"

sendmail.ini:

smtp_server=smtp.gmail.com
smtp_port=587
default_domain=gmail.com
auth_username=powerfulcar12@gmail.com
auth_password=password
force_sender=powerfulcar12@gmail.com
P.A
  • 741
  • 4
  • 16
  • Did sendmail work for you? – Linial Aug 25 '14 at 21:24
  • 2
    Check your ([error](http://php.net/manual/en/function.error-reporting.php)) logs and/or Spam box. – Funk Forty Niner Aug 25 '14 at 21:24
  • 1
    Does your server require an authenticated email address to prevent spam? Check with your hosting provider. – Dylan Hildenbrand Aug 25 '14 at 21:25
  • Not all servers have a public SMTP, some require an authenticated user. – Wobbles Aug 25 '14 at 21:28
  • Did you bother checking the return value of the mail() call? If that returns true, then your problem is somwhere farther down the line at the mail server level. – Marc B Aug 25 '14 at 21:29
  • Try `SMTP Port: 465` - *"If you tried configuring your SMTP server on port 465 (with SSL) and port 587 (with TLS), but are still having trouble sending mail, try configuring your SMTP to use port 25 (with SSL)."* - Add error reporting to the top of your file(s) right after your opening ` – Funk Forty Niner Aug 25 '14 at 21:32

1 Answers1

0

Dont use sendmail PHP function directly. It does not follow any RFC mailing specifications, it's just very simple PHP function. It used to be sufficient years ago before many RFCs came out :-)

Use some PHP mailing library that will create correct mail headers + body and send email for you (via SMTP, POP3 or sendmail). I would recommend either PHPMailer or SwiftMailer - see this thread on PHP mailing software.

You may also be interested in testing emails locally without sending them out of your network - see here how to setup environment.

Community
  • 1
  • 1
lubosdz
  • 4,210
  • 2
  • 29
  • 43
  • Can you name any specification or functionality, `mail()` is not capable of? It's working perfect as is. Can put headers into, can prepare multipart, can deliver to SMTP and authenticate. What else do you need? – Daniel W. Aug 25 '14 at 21:57
  • P.S this is not an answer to the question – Daniel W. Aug 25 '14 at 22:04
  • Using external library MAY potentially fix the issue regarded in this question e.g. by composing correct email body or correctly handling SMTP communication. It is not possible to answer directly since no exact error message or error log was provided. Another benefit of using such a library is efficiency - e.g. embedding inline images would be tremendous job with pure sendmail function - but hey - why reinvent the wheel ? :-) – lubosdz Aug 27 '14 at 07:45