0

I cant get the mail() to work not matter what I try. Ive used this successfully over the years but for some reason i just cant get it to work.

Ive tried the following from other questions around here:

ini_set( 'sendmail_from', "dev@localhost.com" ); // My usual e-mail address
ini_set( 'SMTP', "localhost.com" );  // My usual sender
ini_set( 'smtp_port', 25 );

(correct) php.ini

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = localhost.com
smtp_port = 25

I can ping localhost, localhost.com (used currently for email validatin on localdev) and 127.0.0.1

I have tried netstat and port 25 is "LISTENING" when server is running. I can send/receive mail from Live mail - but not PHP :( no errors either.

mail("dev@localhost.com", "subj", "test message");

Im running win7, tried with firewall off, last download xampp around Dec 2013 so php v is quite current. My folder is in D:\xampp not C - im not using sendmail but mail so it should just work from any directory. Ive also set the sendmail_from to a valid email to no avail...

And yes I have been restarting the webserver after each change.

Im running argosoft webserver free which ive used for a few years. As mentioned I can send mail form Live mail, just not from php file.

FstaRocka
  • 278
  • 1
  • 2
  • 15

1 Answers1

0

Ah: the answer:

I just need to configure D:\xampp\sendmail\sendmail.ini By default, it contains the line

smtp_server=mail.mydomain.com

I had to change it to

smtp_server=localhost

Also - straight mail(to,subject,message) STILL didnt work, as per the manual windows require a from header - so this (from manual) worked:

      $to      = 'dev@localhost.com';
      $subject = 'the subject';
      $message = 'hello';
      $headers = 'From: dev@localhost.com' . "\r\n" .
          'Reply-To: dev@localhost.com' . "\r\n";

      mail($to, $subject, $message, $headers);

Sendmail answer taken from :

stackoverflow.com/questions/13100659/no-mail-received-in-inbox-with-xampp-1-8-0-mercurymail-and-mail

Community
  • 1
  • 1
FstaRocka
  • 278
  • 1
  • 2
  • 15