Incoming connections to the IMAP server at imap.gmail.com:993 and to the POP server at pop.gmail.com:995 require SSL. The outbound SMTP server, smtp.gmail.com, requires TLS. Use port 465 or port 587 if the client starts with plain text before issuing the STARTTLS command.