Reputation: 1
I am unable to receive confirmation email because it kept showing this error message and I have try cross checking the code I don’t get the issue.
This is the error message:
Fatal error: Uncaught PHPMailer\PHPMailer\Exception: Invalid address: (to): gerald in C:\PerfLogs\htdocs\AuthSystem\vendor\phpmailer\phpmailer\src\PHPMailer.php:1094 Stack trace: #0 C:\PerfLogs\htdocs\AuthSystem\vendor\phpmailer\phpmailer\src\PHPMailer.php(1014): PHPMailer\PHPMailer\PHPMailer->addOrEnqueueAnAddress('to', 'gerald', '') #1 C:\PerfLogs\htdocs\AuthSystem\code.php(26): PHPMailer\PHPMailer\PHPMailer->addAddress('gerald') #2 C:\PerfLogs\htdocs\AuthSystem\code.php(53): sendemail_verify('gerald', 'fimmel146@gmail...', 'aa6fc4003742908...') #3 {main} thrown in C:\PerfLogs\htdocs\AuthSystem\vendor\phpmailer\phpmailer\src\PHPMailer.php on line 1094
I tried going’s through the lines stated above and this is the code on line 1094
if ($this->exceptions) { throw new Exception($error_message);
Line 1014: return $this->addOrEnqueueAnAddress('to', $address, $name);
Code.php 26 : $mail->setFrom("[email protected]", $name); $mail->addAddress($name);
Code.php 53: sendemail_verify("$name","$email","$verify_token"); echo "sent or not ?";
Upvotes: 0
Views: 510
Reputation: 37730
This is a very straightforward issue.
gerald
)Two ways to solve this:
PHPMailer provides a validateAddress
method you can use (it’s the same one that’s used internally).
Upvotes: 0