The google documentation says that ports 465 or 587 should be used for connections to the SMTP server. It seems that Mail_smtp uses 25 by default. Try an explicit value of 465 or 587 with the 'port' parameter
$smtp = Mail::factory(
'smtp',
array('host' => $host,
'port' => 465, // explicit port 465 or 587
'auth' => true,
'username' => $username,
'password' => $password),
);