I have configured the php.ini and sendmail.ini on in XAMPP to send emails and its working fine. Now when i change the code in php to use SMTP its not working... Its using the same host, same smtpsecure, same port, same email as in XAMPP and its not working...
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=1234
[email protected]
php.ini
[mail function]
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = [email protected]
sendmail_path = "\"D:\xampp\sendmail\sendmail.exe\" -t"
For Win32 only.
http://php.net/sendmail-from
sendmail_from = [email protected]
and my php code
<?php
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->Port = 587;
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = '1234'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->setLanguage('pl', './vendor/phpmailer/phpmailer/language/phpmailer.lang-pl.php');
$mail->setFrom("[email protected]");
$mail->addAddress('[email protected]'); // Add a recipient // Name is optional
$mail->IsHTML(true);
$mail->Subject = "Prośba o dostęp demo";
$mail->Body = "<p>Wysłano z formularza kontaktowego na stronie bhp.xyz.pl.</p>
</p>";
if(!$mail->Send()){
echo "\n"."Mailer Error: " . $mail->ErrorInfo;
}
else{
echo "Message sent!";
}
?>
Errors: SERVER -> CLIENT: 220 smtp.gmail.com ESMTP f40sm329317edb.7 - gsmtp CLIENT -> SERVER: EHLO PhpStorm 2017.1 SERVER -> CLIENT: 501-5.5.4 HELO/EHLO argument "PhpStorm 2017.1" invalid, closing connection.501 5.5.4 https://support.google.com/mail/?p=helo f40sm329317edb.7 - gsmtp SMTP ERROR: EHLO command failed: 501-5.5.4 HELO/EHLO argument "PhpStorm 2017.1" invalid, closing connection.501 5.5.4 https://support.google.com/mail/?p=helo f40sm329317edb.7 - gsmtp CLIENT -> SERVER: HELO PhpStorm 2017.1 SERVER -> CLIENT: SMTP ERROR: HELO command failed: SMTP NOTICE: EOF caught while checking if connected SMTP Error: Could not connect to SMTP host. SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting