1
Well, I researched about the error, many users said that should be added the ssl://
at the smtp.google.com
or the tls://
at the imap.google.com
, using ports 465(or 993 as an alternative) and 587 respectively.
I tested several user settings of the stackoverflow itself, none managed to put an end to 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);
Notice 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 ?
that’s right, it gave error with both, but apparently it’s blocking on the gmail server itself
– Murilo Melo
@Murilo Sure it’s exactly the same message right? Well, I’ll trust :) ... make a test, remove the spaces of
sendmail_from = [email protected]
, thus[email protected]
.– Guilherme Nascimento
rotated without spaces
– Murilo Melo
@Murilogambôa edited the answer and added this, I will delete all my comments, if you need anything else let me know
– Guilherme Nascimento