Reputation: 231
I am using PHPMailer like always however this time instead of a static email like below which is working fine:
$mail->AddAddress('[email protected]');
I want to use:
$mail->AddAddress(".$email.");
But I face below error:
Fatal error: Uncaught exception 'phpmailerException' with message 'Invalid address: '[email protected].' in /var/www/html/project/process/class.phpmailer.php:774 Stack trace: #0 /var/www/html/project/process/class.phpmailer.php(711): PHPMailer->addAnAddress('to', '[email protected]', '') #1 /var/www/html/project/process/process.php(45): PHPMailer->addAddress('[email protected]') #2 {main} thrown in /var/www/html/project/process/class.phpmailer.php on line 774
I appreciate any guidance.
Upvotes: 0
Views: 283
Reputation: 273
You have your .'s inside the quotation marks. If your just wanting to add the email address then just do $mail->AddAddress($email). If for some reason you want to have the email address quoted, and I'm not sure phpmailer will accept this you would using something like $mail->AddAddress('"'.$email.'"');
Upvotes: 1