Using GMail with DSpace

gmailFrom time to time a DSpace repository will send emails. It does this when new users are added, when new items are added, when workflow tasks need to be completed, when exports have completed etc etc. For DSpace production servers this is normally trivial to set up; enter the name of your email server in the configuration file, enter the email address that emails should be sent from, and it usually just works

However for developers working on DSpace, it can be a bit harder. For good reasons (e.g. spam reduction etc), many institutions make their SMTP email servers accessible only from within their network. So if you are working on DSpace from home, a cafe, or on the train, you don’t have access to your institutional network because you don’t want to bother running VPN. An ideal solution to this problem would be to use a third party SMTP server outside of your institution which you can use which developing. An ideal candidate for this is Google’s GMail.

At present though, DSpace does not allow you to configure some of the more complex aspects of email server configuration like enabling SSL connections, or which SocketFactory to use. These need to be set in order to connect securely to the GMail servers. We’ve had an open issue in the DSpace JIRA issue tracking system to address this, and it has now been included ready for DSpace version 1.6, and can be easily back ported to earlier versions.

To use the GMail servers, configure dspace.cfg as follows:

# SMTP mail server
mail.server=smtp.gmail.com

# SMTP mail server authentication username and password (if required)
mail.server.username = your-user-name@gmail.com
mail.server.password = your-gmail-password

# Pass extra settings to the Java mail library. Comma separated, equals sign between
# the key and the value.
mail.extraproperties = mail.smtp.socketFactory.port=465, \
           mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory, \
           mail.smtp.socketFactory.fallback=false

If you are a Google Apps user this will also work if you substitute the username with your Google Apps email address.

15 thoughts on “Using GMail with DSpace

  1. Rodrigo Dalmonico

    Man you do a good job here, i try to configure but it doesnt work, can you help me to fix it?
    Thank you.

  2. Nasser Al-Kindi

    Thanks a lot Stuart Lewis, I did works to me thanks you.
    I appreciate your effort to describe the solution.

  3. Armando

    how I can change the log path dspace users of XMLUI to jspui, when I send the confirmation email you send me the url like this:
    localhost: 8080/xmlui? token125sdaasd5 but the log files are on localhost: 8080/jspui/register.

  4. Dspace user

    I have changed the config file settings as mentioned but still not working.Also I want ot confirm that both the Dspace -src and Dspace folders config file needs to be changed

  5. Bruce Jensen

    An important thing to watch for: Gmail might initially deny the “suspicious” login from the unfamiliar DSpace domain. So if you get mail errors in DSpace after following Stuart’s instructions, check first by logging into the Gmail account. If that’s the problem you’ll see an unmissable bright red bar across the top of the page. Google then enables you to allow connections from the DSpace host.

  6. Onkar Rai

    Hi,

    I am using Dspace-3.1-src-release on Windows XP. While creating administrator i.d C:\Dspace\bin\dspace create-administrator
    I got

    Creating an initial administrator account
    E-mail address: onkar.ims@gmail.com
    First name: Onkar
    Last name: Rai
    WARNING: Password will appear on-screen.
    Password: xxxxxxxxxxx
    Again to confirm: xxxxxxxxxxx
    Is the above data correct? (y or n): y
    Exception: null
    java.lang.NullPointerException
    at java.util.regex.Matcher.getTextLength(Unknown source)
    at java.util.regex.Matcher.reset(Unknown source)
    at java.util.regex.Matcher.(Unknown source)
    at java.util.regex.Pattern.matcher(Unknown source)
    at org.dspace.storage.rdbms.DatabaseManager.findByUnique(DatabaseManager.java:504)
    at org.dspace.storage.rdbms.DatabaseManager.find(DatabaseManager.java:472)
    at org.dspace.eperson.Group.find(Group.java:682)
    at org.dspace.administer.CreateAdministrator.createAdministrator(CreateAdministrator.java:234)
    at org.dspace.administer.CreateAdministrator.negotiateAdministratorDetails(CreateAdministrator.java:211)
    at org.dspace.administer.CreateAdministrator.main(CreateAdministrator.java:82)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown source)
    at java.lang.reflect.Method.invoke(Unknown source)
    at org.dspace.app.launcher.ScriptLauncher.main(ScriptLauncher.java:183)

    I tested database connectivity . Its connected successfully
    C:\Dspace\bin\dspace test-database
    Testing connection -
    Connected sucessfuly

    But when I tested E-Mail setting I got an Error
    C:\Dspace\bin\dspace test-email
    got Error sending Email:
    -Error: javax.mail.MessegingException: Could not connect to SMTP Host: smtp.gmail.com, port :25;
    Please see the Dspace documentation for assistance.

    Kindly Help me to Overcome this Problem.

    Thanks in Advance

    Regards,
    Onkar Rai

  7. Pingback: Usar Gmail como servidor SMTP | Blog Rodrigo Torrens

  8. djanahana

    hi,

    i have my dspace application in here, i have try to follow those steps but i didn’t find the correct result, any help i will be aprreciate.

    another question, if you guide me how I can delete the 8080/jspui from the URL I will be apreciate

    thanks in advance

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>