Can't send using Mail. I get "The SMTP connection to server "smtp.gmail.com" failed."
The most common issues with SMTP can come from 


Anti-virus software
Firewalls
ISP Restrictions or Blocks


Since your problem is sporadic, I would guess it isthe Virus app if you have any installed.

There is a test you can do in Terminal with "Telnet"

Basic connectivity test is done with depending on what port you're using to send, type 'telnet smtp.gmail.com 25' or 'telnet smtp.gmail.com 587' in the Terminal prompt window and press Enter

source: http://www.socketlabs.com/blog/diagnosing-smtp-service-connection-issues/