2

i'm trying to send email from localhost using php, but failed the code like this

<?php
$to= "fahmie.art98@gmail.com";
$subject = "this is test";
$messages= "this is message test, congrats, your success"

if( mail($to, $subject, $messages) ) {
echo "success guys";
}
else{
echo "failed guys";
};

?>

how to solve the problems? i'm using linux. and how to configure my XAMPP to send an email on localhost?

M. Fahmi Ulul Azmi
  • 90
  • 1
  • 3
  • 15
  • 2
    Take a look at [this answer here.](http://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost) – Brian Schroeter Sep 17 '16 at 01:08

1 Answers1

1

you can configure C:\xampp\php\php.ini and c:\xampp\sendmail\sendmail.ini for gmail to send mail.

in C:\xampp\php\php.ini find extension=php_openssl.dll and remove the semicolon from the beginning of that line to make SSL working for gmail for localhost.

in php.ini file find [mail function] and change

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

Now Open C:\xampp\sendmail\sendmail.ini. Replace all the existing code in sendmail.ini with following code

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=your-gmail@gmail.com
auth_password=your-gmail-password
force_sender=your-mail-gmail-id@gmail.com

Now you have done!! Enter your gmail account

Sunny
  • 402
  • 4
  • 15