I’m trying to set up a small contact form, and I’ve been having difficulties in sending emails, the code in question works correctly on the local server (wamp server), since I appreciate it
You do have those setup correctly right? For your password, you need to turn on “Allow Less Secure Apps” in your Google Account, and it is recommended you turn on 2FA (two-factor authorization) and generate an App Password instead of using your real Google Account password.
Thanks
To get a Google App Password:
Go to myaccount.google.com
Select “Security”
Select “App Passwords”
Select “Mail” and “Custom Name” from the dropdowns
Copy the provided password into your application. Note that once you close the window with the password, you will not be able to view the password again, you will have to generate a new one.