1
I started using the PHPMailer
, and is working but would like to know if there is how the sender is the email that the user typed in my form.
Note: It sends the form data field: name, subject and message.
Follow the configuration that is:
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'senha';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->IsHTML(true);
//$mail->FromName = 'teste';
//$mail->From = '[email protected]';
$mail->setFrom('[email protected]', 'teste');
$mail->addAddress('[email protected]');
$mail->Subject = 'E-mail PHPMailer';
$mail->Body = '<h1>Mensagem enviada via PHPMailer</h1>';
if($mail->Send()){
echo 'Enviado com sucesso !';
}else{
echo 'Erro ao enviar Email:' . $mail->ErrorInfo;
}
I tested as requested and without success. The email I’m receiving is still me as sender.
– Max Rogério
You are using the Gmail server to send messages and the terms prohibit sending emails from outside the network. This line places the sender’s data in the "reply to" field in order to facilitate contact and identification.
– Rene Freak
Vlw! Tested here worked as you explained... But there is some way to receive the sender with the email that the user type?
– Max Rogério
This will depend on the provider. In this case, you use Gmail, so you can’t. If you used a provider that allowed, then just do something similar to this line:
$mail->setFrom($emailFrom, $nameFrom);
– Rene Freak
Blz! Got it... Thank you very much asshole.
– Max Rogério