Rui K. answered 05/05/23
Seasoned Online Tutor & JavaScript Expert
The error message suggests that the SMTP server does not support authentication. One possible reason for this error could be due to incorrect credentials or configuration settings.
To resolve this issue, you can try the following troubleshooting steps:
- Double-check your Gmail account credentials and make sure they are correct.
- Make sure you have enabled "Less Secure Apps" on your Google account. You can do this by going to your Google Account Settings > Security > Less secure app access.
- Try using SSL encryption by changing the port to 465 instead of 587.
-
Try enabling STARTTLS encryption by adding the line
$smtp->startTLS();
before sending the email.
Here's an updated version of your code with these changes included:
Make sure to replace the username and password values with your actual Gmail account credentials. Also, set debug
to true if you want to see detailed error messages in case something goes wrong.