Using Gmail as a Crowd Mail Server
This page describes using Gmail for an outgoing mail server. It requires importing Gmail's SSL certificate.
Configuring GMail for Outgoing Mail (SMTP)
- Download OpenSSL:
Import the SSL certificate from Gmail:
Windows: Double-click the openssl file from the directory that gets installed. Run:
s_client \-connect smtp.gmail.com:465
openssl s_client \-connect smtp.gmail.com:465
- From the output, you want only the alphanumeric string between the lines which say 'BEGIN CERTIFICATE' and 'END CERTIFICATE' (inclusive). Copy the results into a file called gmail.cert using your favorite text editor.
Exit the openssl prompt, and return to your Java installation's
bindirectory. Import the cert into your keystore:
From Sun´s Documentation on Keytool:
A keystore is created whenever you use a -genkey, -import, or -identitydb command to add data to a keystore that doesn't yet exist. More specifically, if you specify, in the -keystore option, a keystore that doesn't yet exist, that keystore will be created. If you don't specify a -keystore option, the default keystore is a file named .keystore in your home directory. If that file does not yet exist, it will be created."
keytool \-import \-alias smtp.gmail.com \-keystore $JAVA_HOME/jre/lib/security/cacerts \-file C:\path\to\gmail.cert
sudo keytool \-import \-alias smtp.gmail.com \-keystore $JAVA_HOME/jre/lib/security/cacerts \-file /path/to/gmail.cert
The default keystore password is 'changeit'.
- Configure the JNDI Resource as described on Configuring your Mail Server
If you receive an error using the port 465 please give it a try using the port 587.
To avoid spamming some network providers are not allowing standard ports to send mail.