Send email using the GMail SMTP server from a PHP page

The new GMail SMTP server is designed to allow users to send email messages from a PHP page. It is designed to work with all GMail accounts and uses a PHP library that has been extensively tested and is compatible with PHP 5.3.2 and up.

Send email using the GMail SMTP server from a PHP page

I am trying to send an email via GMail's SMTP server from a PHP page, but I get this error:

authentication failure [SMTP: SMTP server does no support authentication (code: 250, response: mx.google.com at your service, [98.117.99.235] SIZE 35651584 8BITMIME STARTTLS ENHANCEDSTATUSCODES PIPELINING)]

Step 1: Download PHPMailer library from this github link. ...

Step 2: Writing the PHP Code to make an SMTP connection. ...

Step 3: Include packages and files for PHPMailer and SMTP protocol: ...

Step 4: Initialize PHP Mailer and set SMTP as mailing protocol: