I started using PHPMailer
, and it's working but I'd like to know if there's a way for the sender to be the email that the user entered on my form.
Note: It sends the form data field: name, subject, and message.
Here is the setting 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;
}