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 (formulario@....), however, when sending to the client, set the parameter From
as the contact email (contact@.... ), which is from Gmail as well (I configured it in the email account of the form so that it could sign as the contact).
When sending this email, I send a second email to the contact itself, but this, in turn, I’m trying to define as the customer’s email, but Gmail itself does not allow the sent email to be signed by a different email. Is there any alternative to that?
- Email and password have been 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();
The problem itself is not in the class but in Gmail. Gmail that does not allow From to be changed..
– Julyano Felipe
So. Phpmailer has the
addAddress
,addCC
andaddBCC
for OT submissions. From only part of a place. So I say you have to instantiate again to send that second email.– William Aparecido Brandino
Yes, that I know. The problem is not to do the second sending of email, but to change the Gmail from. I want to send an email, but in another name/email. That’s what the setFrom function does, but it doesn’t work with Gmail emails.
– Julyano Felipe
Edited response with what I found later on the doc and in my codes.
– William Aparecido Brandino