0
I have records on MySql
, basically with columns:
usuario, emailusuario, descricao, responsavel, emailresponsavel
.
I need, when a new registration is made, send an email to the user himself (emailusuario
) and to the responsible (emailresponsavel
).
I use Phpmailer, with an account Gmail
for submissions, but the problem is, that this way the email arrives with sending email to the Gmail account and not with the sender’s email (that would be what makes the new registration), even setting the $mail->SetFrom('[email protected]','usuario');
.
The $mail->AddReplyTo()
works normally.
I wonder if this is because it is authenticated by Gmail
, for being TLS
, or some other reason, and if there’s another way to do it if the problem is the PHPMailer
. I need to do this, regardless if I have to change the SMTP
or biblioteca
.
Sending script:
require_once '/PHPMailer/PHPMailerAutoload.php';
$srvNome = 'smtp.gmail.com';
$srvPort = '587';
$srvEmail = '[email protected]';
$srvSenha = '****';
$emailAssunto = 'NOVO REGISTRO';
$emailDestinatario = $emailDest1;
$titulo = 'NOVO REGISTRO';
$conteudo = "teste";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->CharSet = 'UTF-8';
$mail->Host = $srvNome;
$mail->Port = $srvPort;
$mail->Username = $srvEmail;
$mail->Password = $srvSenha;
$mail->AddReplyTo($emailRemetente,$remetenteNome);
$mail->SetFrom($emailRemetente,$remetenteNome);
$mail->IsHTML(true);
$mail->Subject = $emailAssunto;
$mail->Body = $conteudo;
$mail->AddAddress($emailDestinatario);
if(!$mail->Send()) echo 'erro';