Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29755

How to send an email from localhost using XAMPP? [closed]

$
0
0

I'm trying to send an email using XAMPP. I read many articles and forum threads with suggestions for solving this problem, and tried many combinations, but was unsuccessful so far.

This is my PHP code:

  $to_email = "myemail@gmail.com";
  $subject = "This is a test";
  $body = "Hello, this is a test.";
  $headers = "From: myemail@gmail.com";

  if (mail($to_email, $subject, $body, $headers)) {
    echo 'success';
  } else {
    echo 'failure';
  }

The output is "failure", and the email is not received.

My php.ini (relevant parts):

extension=php_openssl.dll
[mail function]
SMTP=smtp.gmail.com
smtp_port=465
sendmail_from = myemail@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=Off

My sendmail.ini:

smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=auto
error_logfile=error.log
debug_logfile=debug.log
auth_username=myemail@gmail.com
auth_password=mypassword

pop3_server=
pop3_username=
pop3_password=

force_sender=myemail@gmail.com
force_recipient=
hostname=

Notes:

  1. I tried replacing "465" with "25" and "587", but the result was the same.

  2. I tried "hostname=localhost", but the result was the same.

  3. I configured my Gmail account to support less secure app, as I read somewhere it might be helpful, but it didn't solve the problem.

I'd appreciate any advice.

Thanks


Viewing all articles
Browse latest Browse all 29755

Trending Articles