How to add SMTP mailing in phpmailer?

Asked

Viewed 173 times

2

Good morning,

I have the following code to send an e-mail via Phpmailer.

<?php

    $GetPost = filter_input_array(INPUT_POST,FILTER_DEFAULT);

    $Erro      = true;
    $Tipo      = $GetPost['tipo'];
    $Nome      = $GetPost['nome'];
    $Email     = $GetPost['email'];
    $Telefone  = $GetPost['telefone'];
    $Cargo     = $GetPost['cargo'];
    $Curriculo = $_FILES['curriculo'];
    $Mensagem  = $GetPost['mensagem'];

    include_once 'PHPMailer/class.smtp.php';
    include_once 'PHPMailer/class.phpmailer.php';

    $Mailer = new PHPMailer;
    $Mailer->CharSet = "utf8";
    $Mailer->SMTPDebug = 3;

    $Mailer->FromName = "Jogo Digital";
    $Mailer->From = "[email protected]";
    $Mailer->AddAddress("[email protected]");
    $Mailer->IsHTML(true);
    $Mailer->Subject = "Novo currículo \"Trabalhe Conosco\" - {$Nome}";
    $Mailer->AddAttachment($Curriculo['tmp_name'], $Curriculo['name']);
    $Mailer->Body = "
    Novo currículo enviado por {$Nome}<br />
    Tipo: {$Tipo}<br /><br>
    <b>Dados:</b><br /><br>
    Email: {$Email}<br>
    Telefone: {$Telefone}<br>
    Cargo: {$Cargo}<br>
    Mensagem: {$Mensagem}<br>
    Curriculo: {$Curriculo}
    ";

    if(!$Mailer->Send()){
        echo "<script>alert('Não foi possível enviar, tente novamente!');window.history.back();</script>";
    } else {
        echo "<script>alert('Curriculo enviado com sucesso!');window.history.back();</script>";
    }

What should I enter in this code to send by smtp? Because the way it is now, all emails are falling into SPAM.

Thank you!

1 answer

2


$mail->isSMTP(); // Define que a mensagem será SMTP    
$mail->Host = 'mail.dominio.com.br'; // Endereço do servidor SMTP
$mail->SMTPAuth = true;
$mail->Username = '[email protected]'; // Usuario
$mail->Password = 'senhadeemail123'; // Senha
  • Could you talk more about your answer? I believe it would bring more quality to her and the site in general.

Browser other questions tagged

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