PHPMailer alternative Gmail From

2

I have a website where there is a contact form.

The email sent by this form (Gmail), I use a specific only for the site (form @ .....), however, when sending to the client, set the parameter From as the (contact @ ....), which is from Gmail as well (I set up the form's email account so he could sign up as the contact).

When sending this email, I send a second email to the contact itself, however the latter, in turn, I'm trying to define as the client's email, but Gmail itself does not allow the e- mail sent is signed by a different email. Is there any alternative to this?

  • Email and password were hidden

Code:

  $nomeCliente = $_POST['nome'];
  $emailCliente = $_POST['email'];
  $emailEmpresa = "[email protected]";
  $assuntoE1 = '=?UTF-8?B?'.base64_encode("Mil Blocos - Formulário do Website").'?=';
  $assuntoE2 = '=?UTF-8?B?'.base64_encode($_POST['assunto']).'?=';
  $mensagem = $_POST['mensagem'];

  $mail = new PHPMailer();
  $mail->isSMTP();
  $mail->CharSet = 'UTF-8';
  $mail->Host = 'smtp.gmail.com';
  $mail->SMTPAuth = true;
  $mail->Username = '[email protected]';
  $mail->Password = 'minhasenha';
  $mail->Port = 587;
  $mail->SMTPSecure = 'tls';
  $mail->setFrom($emailCliente, $nomeCliente);
  $mail->addAddress($emailEmpresa);
  $mail->Subject = $assuntoE2;
  $mensagem = 'E-mail do cliente: <br />' . $emailCliente . '<br /><br />' . 'Mensagem: <br />' . $mensagem;
  $mail->MsgHTML($mensagem);

  $mail->send();
    
asked by anonymous 19.10.2016 / 17:34

2 answers

0

Can you use another lib? Try SwiftMailer: link

Another thing you can do is, instead of setting From, set the ReplyTo. The email will be sent by the @ form account ... but the answers go to the contact @ ...

    
19.10.2016 / 20:00
0

It has to be another code set for sending this. I've come across this problem and I've only been able to make another call in the class.

EDIT : After submitting, use the ClearAddress() class. After sending the first e-mail, clean it up and add another recipient.

    
19.10.2016 / 18:06