1
<?php
require 'funcoes/PHPMailer-master/PHPMailerAutoload.php';
$email = $_POST['email'];
$nome = $_POST['nome'];
$titulo = $_POST['titulo'];
$mensagem = $_POST['mensagem'];
$mail = new PHPMailer;
$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'meuemail';
$mail->Password = 'senha';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->From = $email;
$mail->Sender = $email;
$mail->FromName = $nome;
$mail->AddAddress('meuemail', 'Milton Viziak');
$mail->AddAddress('meuemail');
$mail->Subject = $titulo;
$mail->Body = $mensagem;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
my doubt is because I am sending email to me even if I place from and Sender with the email received in the form ?
the
AddAddress
can’t be your email, becauseAddAddress
is the recipient, in this field inform the recipient you want, in case the return form.– Gabriel Rodrigues
but the addressee in the case is me. and as such informs the return of the form ?
– Milton Viziak
You must put the variable
$email
in the$mail->AddAddress($email, 'Milton Viziak');
– MeuChapeu
but the $email variable is just the email of the guy who filled out the form.
– Milton Viziak
then, after all, to which email should be sent?
– Daniel Omine
If the recipient is you of course you will receive the email yourself.
– Franchesco