I'm trying to configure Sendmail through XAMPP to send email. In my sendmail.ini I have these settings:
# Set default values for all following accounts.
logfile "C:\xampp\sendmail\sendmail.log
account Gmail
tls on
port 587
tls_certcheck off
host smtp.gmail.com
from myemail@gmail.com
auth on
user myemail06@gmail.com
password mypassword
account default : Gmail
I've created a test script like this:
$to = "testemail@btinternet.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$headers = "From: myemail06@gmail.com" . "\r\n";
if (mail($to, $subject, $body, $headers)) {
echo ("Message successfully sent!");
} else {
echo ("Message delivery failed...");
}
I get a message to say that the email was sent but it never arrives and in the logs I get:
sendmail: Error during delivery: Must issue a STARTTLS command first.
Does anybody know what the issue could be here?
Thanks in advance!
Gaz
Just to add to the already great responses. Make sure you are running XAMPP as Administrator. That was what fixed it for me.
There is another issue when using Gmail. Gmail now has security so that you must generate an application specific password - you can't use the password you have for your normal Gmail access. I discovered this by trying the examples above and then noticing that in the sendmail folder an error log had been generated. In the error log I came across a message indicating this.
All I had to do was switch the "Allow less secure apps to access your account" to on. I guess this is an alternative to creating an app specific password.
https://support.google.com/accounts/answer/6010255 for info
https://www.google.com/settings/security/lesssecureapps for the switch
Might be worth switching it back off after you're done for security purposes.
These are the most recent Google SMTP server requirements:
Google SMTP Requirements
If you just use SSL it gets complicated with the required Captcha verification test so I just set my SSL to auto which will try TLS when SSL Fails.
I know this is an oldish post but just thought I would share the fact that the following worked for me.
I am currently using a WAMP server on Windows 7 ENT with Apache/2.4.9 (Win64) PHP/5.5.12, and MySQL 5.6.17.
I followed this tutorial: http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/