SMTP connect() failed

Asked

Viewed 889 times

0

Someone can help me, I am a few days trying to solve this error with Phpmailed. I have tried to use 3 different scripts, and always shows SMTP connect() failed, I’ve used the door 465, but gave the same thing... (I put the "My password" only here, in the script is right). (Note: I have already enabled the login for unsafe gmail devices).

    require 'PHPMailerAutoload.php';

    $email = $_POST['txte'];

    // Instância do objeto PHPMailer
    $mail = new PHPMailer;

    // Configura para envio de e-mails usando SMTP
    $mail->isSMTP();

    // Servidor SMTP
    $mail->Host = 'smtp.gmail.com';

    // Usar autenticação SMTP
    $mail->SMTPAuth = true;

    // Usuário da conta
    $mail->Username = '[email protected]';

    // Senha da conta
    $mail->Password = 'minha_senha';

    // Tipo de encriptação que será usado na conexão SMTP
    $mail->SMTPSecure = 'ssl';

    // Porta do servidor SMTP
    $mail->Port = 587;

    // Informa se vamos enviar mensagens usando HTML
    $mail->IsHTML(true);

    // Email do Remetente
    $mail->From = '[email protected]';

    // Nome do Remetente
    $mail->FromName = 'Leandro';

    // Endereço do e-mail do destinatário
    $mail->addAddress($email);

    // Assunto do e-mail
    $mail->Subject = 'E-mail PHPMailer';

    // Mensagem que vai no corpo do e-mail
    $mail->Body = '<h1>Mensagem enviada via PHPMailer</h1>';

    // Envia o e-mail e captura o sucesso ou erro
    if($mail->Send()):
        echo 'Enviado com sucesso !';
    else:
        echo 'Erro ao enviar Email:' . $mail->ErrorInfo;
    endif;
  • Gives a look at that

  • 1

    use $mail->SMTPSecure = 'tls';

  • I looked at the link, changed php.ini and persisted with the same error. using "tls" appeared the following error: stream_socket_enable_crypto(): SSL Operation failed with code 1. Openssl Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:Certificate Verify failed.

  • it seems that SSL REQUIRED by Gmail

  • here with me your code worked only by changing $mail->SMTPSecure = 'tls'; with ssldidn’t work. But my email server is not gmail

  • Check out this post https://answall.com/questions/89690/envio-de-email-via-phpmailer-paragmail

  • In this last link I saw an error, in case the port and Smtpsecure were changed (465 to SSL, and 587 to TLS), but the error persists. PHP.ini has port 465. (with the 25 error persists). I applied Smtpdebug = 1 and returned "Failed to connect to server".

  • I only see problems with gmail. One more post https://answall.com/questions/192302/smtp-error-failed-to-connect-to-server-0?rq=1

  • I reviewed the items the little guy tagged, I opened the firewall door and it’s still the same..

  • I changed the $port of Phpmailer and Autoload from 25 to 465 and appeared: 2018-06-19 01:53:55 SMTP NOTICE: EOF Caught while checking if Connected 2018-06-19 01:53:55 SMTP Error: Could not authenticate. 2018-06-19 01:53:55 SMTP connect() failed.

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.