Set these values in Settings > Email:
Use SMTP: YES
SMTP Hostname: smtp.gmail.com:465
SMTP Security: SSL
Use SMTP Authentication: YES
SMTP Username: firstname.lastname@example.org
SMTP Password: yourpassword
Save these settings and then click "send a test email" to test it works or not.
If it doesn't work: some hosting providers do not allow outside SMTP connections.
Please try turning off the SMTP option to see if a test email will send.
Some hosting providers have the SMTP details setup automatically in the background.
If it still doesn't send with SMTP turned off then please send this message to the hosting provider to see if they can assist:
"Hello, I am trying to configure some PHP software to send email through my Google Apps SMTP account. The script is reporting an error: Could not connect to SMTP host smtp.gmail.com:465 Does this hosting account allow connections to outside SMTP servers? If not, what are the SMTP details I can use in this script? Thanks."