I would like to send an email using Gmail SMTP server through PHP Mailer.
this is my code
If you are using cPanel you should just click the wee box that allows you to send to external servers by SMTP.
Login to CPanel > Tweak Settings > All> "Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)"
As answered here:
"Password not accepted from server: 535 Incorrect authentication data" when sending with GMail and phpMailer