Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;rn E-mail: $email;rnrn Mensagem:rn $mensagem;rnrn Telefone:rn $telefone";
- // Envia o e-mail
- $enviado = $mail->Send();
- // Limpa os destinatários e os anexos
- $mail->ClearAllRecipients();
- $mail->ClearAttachments();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement