kaiquemix 1 Denunciar post Postado Agosto 4, 2016 já vi vários tópicos e sites falando sobre o phpmailer enviando direto pro GMAIL, porem não consigo fazer, aparece o seguinte erro: SMTP -> ERROR: Failed to connect to server: Connection timed out (110) The following From address failed: ***@gmail.com : Called Mail() without being connected <?php session_start(); ob_start(); $nome = $_POST['nome']; $email = $_POST['email']; $telefone = $_POST['tel']; $mensagem = $_POST['mensagem']; if($_POST['nome'] != '' && $_POST['mensagem'] != ''){ require("phpmailer/class.phpmailer.php"); // Inicia a classe PHPMailer $mail = new PHPMailer(); // Define os dados do servidor e tipo de conexão // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= $mail->Host = 'smtp.gmail.com'; $mail->Port = 587; $mail->SMTPAuth = true; $mail->SMTPDebug = 1; $mail->SMTPSecure = 'tls'; $mail->IsSMTP(); // Define que a mensagem será SMTP $mail->SMTPAuth = true; // Usa autenticação SMTP? (opcional) $mail->Username = '***@gmail.com'; $mail->Password = '***'; // Define o remetente // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= $mail->From = "***@gmail.com"; // Seu e-mail $mail->FromName = "Contato Show de Quimica"; // Seu nome // Define os destinatário(s) // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= $mail->AddAddress('***@gmail.com'); $mail->AddReplyTo($email); // Define os dados técnicos da Mensagem // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= $mail->IsHTML(true); // Define que o e-mail será enviado como HTML $mail->CharSet = 'utf-8'; // Charset da mensagem // Define a mensagem (Texto e Assunto) // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= $mail->Subject = "Mensagem de Contato Show de Quimica"; // Assunto da mensagem $mail->Body = "<font style=\"font-size:16px\"><b>Nome:</b> $nome; <br /><b>E-mail:</b> $email; <br /><b>Telefone:</b>$telefone; <br /><br /><b>Mensagem:</b><br />$mensagem</font>"; $mail->AltBody = "Nome: $nome;\r\n E-mail: $email;\r\n\r\n Mensagem:\r\n $mensagem;\r\n\r\n Telefone:\r\n $telefone"; // Envia o e-mail $enviado = $mail->Send(); // Limpa os destinatários e os anexos $mail->ClearAllRecipients(); $mail->ClearAttachments(); } ?> Compartilhar este post Link para o post Compartilhar em outros sites
Beraldo 864 Denunciar post Postado Agosto 5, 2016 Eu criei este código e o uso sempre: http://rberaldo.com.br/enviando-e-mails-com-a-classe-phpmailer/ Funciona 100%, tanto com o SMTP do Gmail quanto com outros SMTPs Compartilhar este post Link para o post Compartilhar em outros sites
kaiquemix 1 Denunciar post Postado Agosto 5, 2016 Eu criei este código e o uso sempre: http://rberaldo.com.br/enviando-e-mails-com-a-classe-phpmailer/ Funciona 100%, tanto com o SMTP do Gmail quanto com outros SMTPs NA HOSPEDAGEM: Tentei colocar tanto tls com 587 tanto ssl com 465, demora um tempão e depois aparece o seguinte erro: Erro do PHPMailer: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Compartilhar este post Link para o post Compartilhar em outros sites
kaiquemix 1 Denunciar post Postado Agosto 5, 2016 Fui tentar em LOCAL e aparece o seguinte erro: Erro do PHPMailer: Extension missing: openssl Compartilhar este post Link para o post Compartilhar em outros sites
Beraldo 864 Denunciar post Postado Agosto 5, 2016 Habilite a extensão openssl no php.ini Compartilhar este post Link para o post Compartilhar em outros sites
kaiquemix 1 Denunciar post Postado Agosto 5, 2016 Habilite a extensão openssl no php.ini Liberei agora fica dando a mesma coisa que na hospedagem: Erro do PHPMailer: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Compartilhar este post Link para o post Compartilhar em outros sites
kaiquemix 1 Denunciar post Postado Agosto 5, 2016 Liberei agora fica dando a mesma coisa que na hospedagem: Erro do PHPMailer: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting BOM, AGORA FOI NO LOCAL, porem dentro da hospedagem ainda continua com o mesmo, demora muito e apresentando que o SMTP não está conectando. Compartilhar este post Link para o post Compartilhar em outros sites
Beraldo 864 Denunciar post Postado Agosto 5, 2016 Habilite o SMTPDebug e veja os logs da conexão. Lá deve ter mais informações sobre o problema Compartilhar este post Link para o post Compartilhar em outros sites
kaiquemix 1 Denunciar post Postado Agosto 5, 2016 Bom apareceu isso: 2016-08-05 19:35:02 Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ( ) 2016-08-05 19:35:02 Connection: opened 2016-08-05 19:35:02 SMTP -> get_lines(): $data is "" 2016-08-05 19:35:02 SMTP -> get_lines(): $str is "220 smtp.gmail.com ESMTP l184sm4990666oib.2 - gsmtp " 2016-08-05 19:35:02 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP l184sm4990666oib.2 - gsmtp 2016-08-05 19:35:02 CLIENT -> SERVER: EHLO mirar.com.br 2016-08-05 19:35:02 SMTP -> get_lines(): $data is "" 2016-08-05 19:35:02 SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [192.185.176.231] " 2016-08-05 19:35:02 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [192.185.176.231] " 2016-08-05 19:35:02 SMTP -> get_lines(): $str is "250-SIZE 35882577 " 2016-08-05 19:35:02 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [192.185.176.231] 250-SIZE 35882577 " 2016-08-05 19:35:02 SMTP -> get_lines(): $str is "250-8BITMIME " 2016-08-05 19:35:02 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [192.185.176.231] 250-SIZE 35882577 250-8BITMIME " 2016-08-05 19:35:02 SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH " 2016-08-05 19:35:02 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [192.185.176.231] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH " 2016-08-05 19:35:02 SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES " 2016-08-05 19:35:02 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [192.185.176.231] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES " 2016-08-05 19:35:02 SMTP -> get_lines(): $str is "250-PIPELINING " 2016-08-05 19:35:02 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [192.185.176.231] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING " 2016-08-05 19:35:02 SMTP -> get_lines(): $str is "250-CHUNKING " 2016-08-05 19:35:02 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [192.185.176.231] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING " 2016-08-05 19:35:02 SMTP -> get_lines(): $str is "250 SMTPUTF8 " 2016-08-05 19:35:02 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [192.185.176.231] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 2016-08-05 19:35:02 Auth method requested: UNKNOWN 2016-08-05 19:35:02 Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH 2016-08-05 19:35:02 Auth method selected: LOGIN 2016-08-05 19:35:02 CLIENT -> SERVER: AUTH LOGIN 2016-08-05 19:35:02 SMTP -> get_lines(): $data is "" 2016-08-05 19:35:02 SMTP -> get_lines(): $str is "334 VXNlcm5hbWU6 " 2016-08-05 19:35:02 SERVER -> CLIENT: 334 VXNlcm5hbWU6 2016-08-05 19:35:02 CLIENT -> SERVER: a2FpcXVlcmJuQGdtYWlsLmNvbQ== 2016-08-05 19:35:02 SMTP -> get_lines(): $data is "" 2016-08-05 19:35:02 SMTP -> get_lines(): $str is "334 UGFzc3dvcmQ6 " 2016-08-05 19:35:02 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 2016-08-05 19:35:02 CLIENT -> SERVER: cmJuMTIzODU2Lg== 2016-08-05 19:35:03 SMTP -> get_lines(): $data is "" 2016-08-05 19:35:03 SMTP -> get_lines(): $str is "534-5.7.14 Please log in via your web browser and " 2016-08-05 19:35:03 SMTP -> get_lines(): $str is "534-5.7.14 then try again. " 2016-08-05 19:35:03 SMTP -> get_lines(): $data is "534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. " 2016-08-05 19:35:03 SMTP -> get_lines(): $str is "534-5.7.14 Learn more at " 2016-08-05 19:35:03 SMTP -> get_lines(): $data is "534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at " 2016-08-05 19:35:03 SMTP -> get_lines(): $str is "534 5.7.14 https://support.google.com/mail/answer/78754 l184sm4990666oib.2 - gsmtp " 2016-08-05 19:35:03 SERVER -> CLIENT: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 l184sm4990666oib.2 - gsmtp 2016-08-05 19:35:03 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 l184sm4990666oib.2 - gsmtp 2016-08-05 19:35:03 SMTP Error: Could not authenticate. 2016-08-05 19:35:03 CLIENT -> SERVER: QUIT 2016-08-05 19:35:03 SMTP -> get_lines(): $data is "" 2016-08-05 19:35:03 SMTP -> get_lines(): $str is "221 2.0.0 closing connection l184sm4990666oib.2 - gsmtp " 2016-08-05 19:35:03 SERVER -> CLIENT: 221 2.0.0 closing connection l184sm4990666oib.2 - gsmtp 2016-08-05 19:35:03 Connection: closed 2016-08-05 19:35:03 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Erro do PHPMailer: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Compartilhar este post Link para o post Compartilhar em outros sites
kaiquemix 1 Denunciar post Postado Agosto 5, 2016 Habilite o SMTPDebug e veja os logs da conexão. Lá deve ter mais informações sobre o problema EM DEBUG $Mailer->SMTPDebug = 1; APARECE ISSO: 2016-08-05 19:37:50 CLIENT -> SERVER: EHLO mirar.com.br 2016-08-05 19:37:50 CLIENT -> SERVER: AUTH LOGIN 2016-08-05 19:37:50 CLIENT -> SERVER: a2FpcXVlcmJuQGdtYWlsLmNvbQ== 2016-08-05 19:37:50 CLIENT -> SERVER: cmJuMTIzODU2Lg== 2016-08-05 19:37:51 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 c184sm7127978oia.25 - gsmtp 2016-08-05 19:37:51 SMTP Error: Could not authenticate. 2016-08-05 19:37:51 CLIENT -> SERVER: QUIT 2016-08-05 19:37:51 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Erro do PHPMailer: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting JÁ $Mailer->SMTPDebug = 2; APARECE ISSO: 2016-08-05 19:39:14 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP l6sm9467316oih.7 - gsmtp 2016-08-05 19:39:14 CLIENT -> SERVER: EHLO mirar.com.br 2016-08-05 19:39:14 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [192.185.176.231] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 2016-08-05 19:39:14 CLIENT -> SERVER: AUTH LOGIN 2016-08-05 19:39:14 SERVER -> CLIENT: 334 VXNlcm5hbWU6 2016-08-05 19:39:14 CLIENT -> SERVER: a2FpcXVlcmJuQGdtYWlsLmNvbQ== 2016-08-05 19:39:14 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 2016-08-05 19:39:14 CLIENT -> SERVER: cmJuMTIzODU2Lg== 2016-08-05 19:39:15 SERVER -> CLIENT: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 l6sm9467316oih.7 - gsmtp 2016-08-05 19:39:15 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 l6sm9467316oih.7 - gsmtp 2016-08-05 19:39:15 SMTP Error: Could not authenticate. 2016-08-05 19:39:15 CLIENT -> SERVER: QUIT 2016-08-05 19:39:15 SERVER -> CLIENT: 221 2.0.0 closing connection l6sm9467316oih.7 - gsmtp 2016-08-05 19:39:15 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Erro do PHPMailer: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Compartilhar este post Link para o post Compartilhar em outros sites
Beraldo 864 Denunciar post Postado Agosto 5, 2016 O log te explica o problema e ainda mostra o link do suporte do Google: https://support.google.com/mail/answer/78754 Siga as orientações do link Compartilhar este post Link para o post Compartilhar em outros sites
kaiquemix 1 Denunciar post Postado Agosto 5, 2016 Obrigado agora foi, Ativei o Captch neste link: https://accounts.google.com/DisplayUnlockCaptcha?lp=1&hl=pt-BR Compartilhar este post Link para o post Compartilhar em outros sites