0

Does not make much sense why FROM field is not been sent as it should be.

This is the code:

    $mail             = new PHPMailer();            

        $mail->IsSMTP(); // telling the class to use SMTP

        //$mail->SMTPDebug  = 1;                   
        $mail->SMTPAuth   = true;                  
        $mail->SMTPSecure = "tsl";                
        $mail->Host       = "smtp.gmail.com";
        $mail->Port       = 587;                  
        $mail->Username   = "gui.desenvolvedor@gmail.com"; 
        $mail->Password   = "***";
        $address = "gui.desenvolvedor@gmail.com";
        $mail->AddAddress($address, "Guilherme");


        $mail->SetFrom("from@from.com.br", "from you");  //<------ HERE
        $mail->AddReplyTo("reply@reply.com.br", "reply be");


        $mail->Subject    = "Email enviado pelo site.";         
        $mail->AltBody    = $mensagem;              
        $mail->MsgHTML($mensagem);

        if(!$mail->Send()) {
            echo "Mailer Erro: " . $mail->ErrorInfo;
        } else {    
            echo "Mensagem Enviada!";
        }

The e-mail I´m receiving is that:

enter image description here

I am using the latest version phpMailer 5.2

Ryan
  • 368
  • 1
  • 10
  • 28
Guilherme Longo
  • 605
  • 3
  • 9
  • 18

1 Answers1

1

It's not your fault - You're doing everything right - but you can't do this because Gmail does not allow you to send from arbitrary addresses. The best you can do is to predefine some aliases in your gmail prefs and use those.

This is covered in the PHPMailer docs and in other questions.

Community
  • 1
  • 1
Synchro
  • 35,538
  • 15
  • 81
  • 104