E-mail with Phpmailer using PHP variable

Asked

Viewed 61 times

0

I am trying to email the Phpmailer class but I am having trouble.

Here I get a good one:

$mail->AddAddress('[email protected]', 'Nome do Destinatário');

But when I put a variable, it won’t... return the following error: "You must provide at least one recipient email address."

$mail->AddAddress('$email', '$nome');

How can I solve this little problem? Thank you!

EDIT: SOLVED.

I did it this way:

' . $email . '
  • Try to figure out why the data of this variable doesn’t arrive there, put your code so we understand

  • You did not solve, because you do not understand how it works simple quotes and compound quotes, need to read about and if the variable $email and $nome for a text does not need quotes ... after all are texts.

  • Can be considered duplicate: https://answall.com/questions/4652/diff%C3%A7a-between-single-double-quote-in-php

1 answer

0

Try to leave it that way, php already treats these two variables as strings, so you don’t have to worry about the quotes(" "), try it that way, just couldn’t find the "$email" email, since you put it in quotes.

$mail->AddAddress($email, $nome);
  • Try to explain the reason for friend’s mistake ...

  • Ready my dear... Edited, I hope it helps you.

  • 1

    Read: https://answall.com/questions/4652/dif%C3%A7a-between-quotes-single-and-double-in-php ai ta the answer ... I do not know if it fits the question as duplicate but, the reason for the concept is this, but, also has another problem of not needing quotes

  • I believe it is not duplicate, but your comment adds enough to solution

Browser other questions tagged

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