0

This is what i have done in php.ini:

[mail function]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

in sendmail.ini:

[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=myemailid@gmail.com
auth_password=mypassword
force_sender=myemailid@gmail.com

And here is the code I wanted to run:

 <?php
$to = 'anotheremail@gmail.com';
$subject = 'Hello from XAMPP!';
$message = 'This is a test';
$headers = "From: myemailid@gmail.com\r\n";
if (mail($to, $subject, $message, $headers)) {
   echo "SUCCESS";
} else {
   echo "ERROR";
}
?>

This is showing me SUCCESS as output. But, I am not receiving any email...

  • Please also the error message you got. – Martin Zabel Feb 18 '16 at 09:10
  • possible duplicate : http://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost/18185233#18185233 – CD001 Feb 18 '16 at 09:13
  • It is for the actual program where I have my PHP mailing code... but, for the program I posted, it just shows "ERROR" as in the code. –  Feb 18 '16 at 09:14
  • @CD001 I have tried them... but still it is not working! –  Feb 18 '16 at 09:16
  • @VyshnaviSamudrala can you enable your errors like ini_set('display_errors', "On"); and then post the actual error message – rahul Feb 18 '16 at 09:20
  • it is just displaying ERROR –  Feb 18 '16 at 09:28
  • Where are you getting that *Server Error 500* ? That implies a misconfiguration in Apache (probably in an .htaccess file) rather than a PHP error ... and if you're getting a 500 Error then the PHP code wouldn't run at all... however if your PHP script is echoing out *ERROR* then the mail function is returning false and you might not have configured Gmail to allow *less secure* apps (assuming the login is correct) : https://support.google.com/accounts/answer/6010255 – CD001 Feb 18 '16 at 09:29
  • I have configured Gmail to allow less secure apps. –  Feb 18 '16 at 09:37
  • Sendmail path correct? I just checked my xampp directory and I've not actually got sendmail "installed" ... I just use a fake smtp server : http://antix.co.uk/Projects/SMTP-Impostor-an-SMTP-server-for-developers – CD001 Feb 18 '16 at 09:50

1 Answers1

0

Are you using it for a local project ? The code will keep showing error as the mail() function has failed to send the mail. Try setting the sendmail_path variable as

sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

This will send all mails to your xammp directory in folder mailoutput. Like "C:\xampp\mailoutput"

  • That folder is empty! I've reinstalled Xampp and made those changes again. But, it is showing "SUCCESS" message as output for my code. But, I am not getting mail... –  Feb 18 '16 at 18:08
  • Strange ! I could following the steps above I could get mail in the mailoutput folder. Try installing **Test Mail Server Tool**. Here you can set up the folder and receive mails sent from localhost. Added link [link](http://www.toolheap.com/test-mail-server-tool/users-manual.html) – priya gupta Feb 19 '16 at 13:01