For some reason the SMTP can occasionally have problems resolving the hostname, so a fix is to use the IP instead. Instead of host:smtp.gmail.com try host:74.125.142.108 and see if that works (it's just the IP of smtp.gmail.com, test by pinging smtp.gmail.com in cmd.exe)