How do I configure Confluence to use Gmail as the mail server?
Remember to generate and use an application specific password if Google's two-factor authentication is enabled.
To configure Confluence to use Gmail as the mail server.
Confluence 5.6 and above
For Confluence 5.6 and above, you can set up Gmail through the admin console
- Go to Admin > Mail Servers
- Click 'Add a new SMTP mail server'
- Fill out your mail account details.
smtp.gmail.comfor the mail server and 587 for the port, and ensure you tick Use TLS:
Confluence 5.5.x and below
For Confluence 5.5.x and below, you will need to create a JNDI mail session and then have Confluence use it, as described below.
To do this for the Confluence distribution, please see Setting Up a Mail Session for the Confluence Distribution.
- Stop Confluence.
Move (don't copy)
activation-1.0.2.jar(if it exists) and
<Confluence Standalone install>/lib. Or if you are using Confluence WAR release, move to
<Tomcat 5 install>/common/libor
<Tomcat 6 install>/lib.
The exact version numbers on these jar files may vary, but that should not matter. As of Confluence 5.2.3, activation-1.0.2.jar no longer exists, and does not need to be moved or downloaded
Do not leave a renamed backup of the jar files in
/confluence/WEB-INF/lib. Even with a different file name, the files will still be loaded as long as it remains in the directory.
Add the following Resource tag in confluence.xml or server.xml located at <confluence-install>/conf, inside the
<Context>node (substituting username and password), so it looks like this:Server.xml
// The context tag here is for illustrative purposes only, to highlight where the Resource tag should be entered. You do not need to copy the Context tag, it will already exist in your file. <Context path="/confluence" docBase="../confluence" debug="0" reloadable="false" useHttpOnly="true"> <!-- Logger is deprecated in Tomcat 5.5. Logging configuration for Confluence is specified in confluence/WEB-INF/classes/log4j.properties --> <Manager pathname="" /> // Copy this Resource tag into the Context tag in your server.xml, and enter your user and password details <Resource name="mail/Session" auth="Container" type="javax.mail.Session" mail.smtp.host="smtp.gmail.com" mail.smtp.port="465" mail.smtp.auth="true" mail.smtp.user="firstname.lastname@example.org" password="foobar" mail.smtp.starttls.enable="true" mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory" /> // End section to copy </Context>
- Restart your Confluence instance.
java:comp/env/mail/Sessionto your JNDI mail configuration from Administration > Mail Servers.
- You may optionally add
<Resource>to see logs generated by JavaMail.
- If your Google account uses 2-step verification you will need to use an application password instead of your password.
- Also, if you find connection errors using the port 465 please change it to 587.