0

Having some issues with Sendmail on Xampp (Windows Installation) - When I try a test Email (See below script)

<?php 
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "xxx@xxx.com";
$to = "xxx@xxx.com";
$subject = "PHP Mail Test script";
$message = "This is a test to check the PHP Mail functionality";
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
echo "Test email sent";
?>

Upon running this script and checking the error.log I get the following error:

'D:\Xampp2\sendmail\sendmail.exe" -t' is not recognized as an internal or external command,
operable program or batch file.

My settings look like so:

PHP.ini

XAMPP: Comment out this if you want to work with an SMTP Server like    Mercury
SMTP = smtp.gmail.com
smtp_port = 465
sendmail_from = katosart@gmail.com
sendmail_path="D:\xampp2\sendmail\sendmail.exe\" -t"

Sendmail.ini

smtp_server= smtp.gmail.com
smtp_port= 465
smtp_ssl= auto
auth_username=katosart@gmail.com
auth_password=(HIDDEN)

I have tried using ports of: 587, 465, 25 for the smtp_port area. Rather stumped on this one - any ideas please? :)

0m3r
  • 12,286
  • 15
  • 35
  • 71
Phil Marsh
  • 53
  • 6
  • What's the stray escaped `\"` double quote supposed to do? – mario Jun 19 '15 at 23:05
  • Can I ask where you mean sorry? :) – Phil Marsh Jun 19 '15 at 23:06
  • I found where you meant, sorry it should have been: "\"D:\xampp2\sendmail\sendmail.exe\" -t" - which I got from: http://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost – Phil Marsh Jun 19 '15 at 23:10
  • GMail requires a separate SMTP per-application password. Though you should rather get rid of that mail()+sendmail.exe workaround. Just use PHPMailer/SwiftMailer instead. – mario Jun 19 '15 at 23:36
  • Not used either before to be honest, I'll look into tutorials for both. Thanks Mario – Phil Marsh Jun 20 '15 at 00:08

1 Answers1

0

OK! So I have worked this out myself by commenting out:

sendmail_path="D:\xampp2\sendmail\sendmail.exe\" -t"

However, I now got an Email from Google saying:

We recently blocked a sign-in attempt to your Google Account 

So the emails are getting through. I worry that this may impact on other recipients receiving the same issue?

EDIT: Getting an error on the running of the above script, the error is:

Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. q2sm18977843wjz.15 - gsmtp in D:\xampp2\htdocs\test-email.php on line 9
Phil Marsh
  • 53
  • 6
  • I've allowed access for less secure apps, retested the script and now get: Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. q2sm18977843wjz.15 - gsmtp in D:\xampp2\htdocs\test-email.php on line 9 – Phil Marsh Jun 19 '15 at 23:17