Well, I've researched the error, many users said that ssl://
to smtp.google.com
or tls://
to imap.google.com
should be added, using ports 465 (or 993 as an alternative) and 587 respectively.
I tested a number of user configurations of the stackoverflow itself, none of them could stop this problem.
php.ini
[mail function]
SMTP=imap.gmail.com
smtp_port=587
sendmail_from = [email protected]
mail.add_x_header=On
sendmail.ini
smtp_server=imap.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
[email protected]
auth_password=xxxxxxx
sending script
<?php
$nome = $_POST["nome"];
$assunto = $_POST["assunto"];
$mensagem = $_POST["mensagem"];
$mensagem = wordwrap($mensagem, 70);
$mensagem = str_replace("\n.", "\n..", $mensagem);
$email = $_POST["email"];
$telefone = $_POST["telefone"];
#Montagem do e-mail
$from = $email;
$to = "[email protected]";
$subject = $assunto;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: {$from}" . "\r\n";
$headers .= "To: {$to}" . "\r\n";
$headers .= "X-Mailer: " . phpversion();
$message = "<p>{$nome}</p><br />
<p>{$email}</p><br />
<p>{$telefone}</p><br />
<br />
<p>{$assunto}</p><br />
<p>{$mensagem}</p>";
mail($to, $subject, $message, $headers);
Warning returned:
mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. b62-v6sm6183858qkj.48 - gsmtp in C:\xampp\htdocs\willy\contact_form.php on line 25
How can I fix the problem?