It wasn't easy: the standard JavaMail configuration didn't work, while Google gave me a lot of wrong and/or outdated information.
Moreover, JavaMail FAQs provide a sample about sending emails via GMail, but it has some problems too.
So I think these bits of information will be helpful to someone trying to accomplish the same task ...
The problem is that GMail uses TLS and the STARTTLS command.
The solution applies to JavaMail 1.4 and JDK 1.4 or higher and is just a matter of configuration.
First, and obviously, enable POP support for your GMail account.
Then, put the following configuration in your properties file:
The key point is the part in bold: enabling the STARTTLS command.
That's the tricky part.
Once created the properties file above, just configure your JavaMail Session object and send your mail message as you'd always do:
Properties props = ...; // <-- Your properties above
Authenticator authenticator = new YourAuthenticator(...);
Session session = Session.getInstance(props, authenticator);
Transport t = session.getTransport();
Feel free to comment on for any question.