PHP MAILER - Error: The following Recipients failed

Asked

Viewed 3,939 times

0

$email = $_REQUEST['email'];

$mail->IsSMTP(); 
$mail->Host = "smtp.***.com.br";
$mail->SMTPAuth = true; 
$mail->Username = 'contato@***.com.br'; 
$mail->Password = '******'; 


$mail->From = $email;  <<<<<<<<<<<<<<ERRO>>>>>>>>>>>>>>>>>>
$mail->Sender = "[email protected]"; 
$mail->FromName = "Contato - www.contato.com.br";

When I use I put the direct value in ($mail->From)= "[email protected]". It works normally, when I put a variable, error, algem can help me?

  • Which error appears?

  • Post the error so we can help better, please !

  • It was not possible to send the email. Error message: SMTP Error: The following Recipients failed: [email protected] SMTP server error: 5.7.1 : Sender address Rejected: Access denied

  • Comment this line $mail->Issmtp();

2 answers

2

You have to wear it like this:

$mail->addAddress("[email protected]"); // email do destinatario (para quem a mensagem devera ser enviada).

$mail->addReplyTo('[email protected]', 'First Last'); // Aqui define um endereço(email) alternativo para resposta.

0

I found the solution.

It was necessary to replace the method for:

$mail->AddReplyTo($email, $nome);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.