0

I saw many questions and answers on Stack Overflow and tried many of them to send a mail from localhost in XAMPP, but all the attempts were futile. Here is my semdmail.ini file:

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=******@gmail.com
auth_password=***
force_sender= *****@gmail.com

My php.ini file contains this

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header = Off

My php file is as follows

<?php
if(mail ('abcd@gmail.com', 'asdf', 'asdf', 'From: vh@gmail.com'))
{
    echo 'success';
}else
{
    echo 'sorry';
}
?>

Though I saw on net, I was unable to find a working solution.

halfer
  • 18,701
  • 13
  • 79
  • 158
bulbasaur
  • 49
  • 1
  • 1
  • 6
  • 2
    `sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"` see if that makes a difference. Add error reporting to the top of your file(s) right after your opening ` – Funk Forty Niner Nov 03 '14 at 18:46
  • No errors are being displayed. and still it's giving the same output. "sorry" – bulbasaur Nov 03 '14 at 19:04
  • http://stackoverflow.com/questions/712392/send-email-using-the-gmail-smtp-server-from-a-php-page – mkaatman Nov 03 '14 at 19:22
  • its giving a bunch of errors as Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\xampp\php\pear\Mail\smtp.php on line 365 – bulbasaur Nov 03 '14 at 19:29

1 Answers1

0

Try:

  • Uncomment "extension=php_openssl.dll" in your php.ini (C:\xampp\php\php.ini)
  • Uncomment and configure in php.ini the section "[mail function]":

_

[mail function]
SMTP = smtp.gmail.com  
SMTP = smtp.gmail.com
smtp_port = 587
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.  
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

Hope it help

Erika Hernández
  • 197
  • 2
  • 2
  • 8
  • It is giving success but the mail can't be seen in the inbox or spam. Thanks for the help...(I used my personal email address instead of abcd@gmail.com) – bulbasaur Nov 04 '14 at 05:01