Using Gmail as a JIRA Mail Server

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

This article applies to JIRA versions 4.3 and below. For all other versions, please refer to Configuring JIRA's SMTP Mail Server to Send Notifications

This page describes how to use a Gmail account as either an SMTP mail server to send notifications from JIRA or a POP3 mail server to receive email messages that create JIRA issues or comments, or both.

Configuring JIRA to use Gmail as an SMTP mail server

  1. Shut down JIRA.
  2. Move (not copy) the 'activation' and 'mail' JAR files from the from the <jira-application-dir>/WEB-INF/lib/ subdirectory of the JIRA Installation Directory to the /common/lib (Tomcat 5.5) or /lib (Tomcat 6) subdirectory of the JIRA Installation Directory (for 'recommended' distributions of JIRA) or the lib/ subdirectory of the application server running JIRA.
    For example, on a *nix-based system, at a shell prompt, change directory into the JIRA Installation Directory (of a 'recommended' distribution of JIRA) and enter the following:

    mv atlassian-jira/WEB-INF/lib/activation-1.1.1.jar lib/; mv atlassian-jira/WEB-INF/lib/mail-1.4.5.jar lib/
  3. Add Gmail as a JNDI resource within the within the <Context/> elements of the /conf/server.xml file. Change your username and password to those required to authenticate against your Gmail account:

    <Resource name="mail/GmailSmtpServer"
        auth="Container"
        type="javax.mail.Session"
        mail.smtp.host="smtp.gmail.com"
        mail.smtp.port="465"
        mail.smtp.auth="true"
        mail.smtp.user="myusername@gmail.com"
        password="mypassword"
        mail.smtp.starttls.enable="true"
        mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
    />
    
  4. If you are not using the built in cacerts file, you will need to add Gmail as a secure server. (Most default configurations can skip this step).

    Click here to expand...
    1. Download OpenSSL:
    2. Import the SSL certificate from Gmail:

      • For Windows: double-click the openssl file from the directory that gets installed. Run

        s_client -connect smtp.gmail.com:465
      • For Linux: run:

        openssl s_client -connect smtp.gmail.com:465
        
    3. 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.           

    4. Exit the openssl prompt and return to your Java installation's bin directory. Import the cert into your keystore:

      • For Windows:

        keytool -import -alias smtp.gmail.com -keystore "%JAVA_HOME%/jre/lib/security/cacerts" -file C:\path\to\gmail.cert
        

        (tick) Tip:

        • "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."
          From Sun´s Documentation on Keytool

      • For Linux:

        sudo keytool -import -alias smtp.gmail.com -keystore $JAVA_HOME/jre/lib/security/cacerts -file /path/to/gmail.cert
        

    (tick) Tip: The default keystore password is changeit

  5. Restart JIRA so that JIRA will acknowledge the JNDI location you defined above.

  6. Follow the instructions in Configuring JIRA's SMTP Mail Server to Send Notifications to configure JIRA's SMTP mail server and at the second part of the configuration, specify in the JNDI Location field (if using the default example above):

    java:comp/env/mail/GmailSmtpServer
    

Configuring Gmail for Incoming Mail (POP)

To use Gmail, for example, as a create and comment mail handler:

If you did not import the SSL certificate from Gmail during configuration of Gmail as an SMTP mail server, refer to the instructions above.

Enable POP access in your Gmail account's settings.

Add a POP3 mail account in JIRA.

Last modified on Jan 14, 2014

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.