Go to Site administration > Server > Email > Outgoing mail configuration

To get the SMTP servers functioning, only four values need to be set:
SMTP hosts: smtp.gmail.com:465 NOTE: Leave out the port (:465) in 1.9.2 or lower
SMTP security: SSL
SMTP username: Your email address @gmail.com or your own domain if using Google Apps
SMTP password: password for the above email account

You may get an email from Gmail saying that an external application is trying to access your account and Google will actually prevent this login process from succeeding.

To prevent this from happening, log into your gmail.com account and then visit: https://accounts.google.com/DisplayUnlockCaptcha
And you will then see the following message:

Sign in using the application you want to authorize access to your account within the next ten minutes.
Google will remember the application after it signs in, and will allow it to access your account in the future
as long as it uses the correct password.

Please also allow access of Less secured apps. After you have done this, you will then be able to send emails through the Google SMTP server.