Главная > project management, redmine, Software > Redmine+IMAP+Gmail = Easy ticket submission via e-mail

Redmine+IMAP+Gmail = Easy ticket submission via e-mail

This post will be about getting the incoming e-mail functionality enabled so that users can send and even update tickets via e-mail.  In-fact, this is quite a powerful feature, «how powerful is it!?»you ask… just a second I’ll get to that in a moment.

First, if you are following along from before then I can assume you are using Redmine under Windows and possibly even have it installed using the Bitnami stack.  I can also assume you probably use Exchange for your e-mail system and more than likely it does not have a Ruby environment on it, nor does it have IMAP enabled.  Finally, I am going to assume that the IT guys would get agitated if you even glanced in the direction of the server room.  How am I doing so far?  Alright, no worries, you should know better than to be playing with the production servers anyways.  We are going to get this incoming e-mail thing working for you in not time, just stay with me.

For outgoing notifications Redmine uses SMTP, which should be no problem to get working in just about any environment.  If all else seems lost just set up a Gmail account an use that for SMTP forwarding.  I will assume there are no problems, just follow the instructions on theRedmine Wiki for setting this up.

Incomming e-mail can be a bit more tricky.  There are a few options but most of them don’t really work well in a Windows environment.  Forwarding e-mails from the mail server requires running a ruby script and is suited to Postfix, Sendmail environments (to be honest you may have your Exchange server behind one of those so you may be able to do this, but hey, I said leave the production systems alone dammit!).  Reading e-mails for the standard input is also not the greatest option since it is a) slow and b) still not all that suitable for a Windows environment.

Fortunately the IMAP option is perfect for us (and imho the best of any of them anyways) so we are going to go with that.  Setting up Imap using a Gmail account is easy.  I just created the account and enabled Imap in the settings.  The harder part is configuring your Redmine server to check it’s e-mails.

The wiki says to create a pycron job to run the mail checking script:

*/30 * * * * redmineuser rake -f /path/to/redmine/appdir/Rakefile redmine:email:receive_imap RAILS_ENV="production" host=imap.foo.bar username=redmine@somenet.foo password=xxx

Close… but I have to take the Windows environment into consideration.  For starters we need to setup the rails environment variables before we run that.  Here is what I did.

  • First download and install the graphical version of pycron.  It will as to set up a service, sayyes.
  • Next, I added a batch file called imapjob.bat that in the apps/redmine/scripts folder.  This is where Bitnami has all it’s service scripts set up and it seemed like a good place for this.  The batch commands are as follows:

CALL C:\BITNAM~1\scripts\setenv.bat
cd C:\BitNami Redmine Stack/apps/redmine
CALL rake redmine:email:receive_imap RAILS_ENV="production" host=imap.gmail.com port=993 ssl=SSL username=myfakebugzemail@gmail.com password=I8URBugz project=unsorted tracker=bug allow_override=project,tracker,priority

  • Obviously you want to replace the relevant paths depending on your installation
  • You may also want to customize the parameters of the script.  The Wiki explains the options you have available.  My setup is like this (this is where you can see the power of this feature):
    • project=unsorted - Adds incomming e-mail tickets to the «unsorted» project by default
    • tracker=bug - Sets new e-mail tickts to «bug» by default
    • allow_override=project,tracker,priority - Allows the user to override (set) the project, tracker and priority values in the body of the e-mail
  • Now you open up pycron and add a job to your crontab, I like it to run every minute so just set all Schedule options to ‘*’ and then set the command to:
    C:\BitNami Redmine Stack\apps\redmine\scripts\imapjob.bat
  • Start your pycron service and set it to Automatic if you want it to start automatically if the server is reset

That should do it.  Make sure you set up your «unsorted» project or whatever you decided to call it and send a test e-mail to that Gmail account.  Try out the overrides too, they are half the power of this feature.  You can e-mail tickets that go to a specific project and have specific options set.  You can also send a new e-mail to an existing ticket, just include the number in the subject, e.g., «Subject: I have fixed #13″ if you wanted to update ticket 13.

But wait, there’s more!  It even takes attachments (apparently, I haven’t had time to test all of the features as I am sitting here writing up this blog instead) so users can attach files, screen-shots, etc when they send an new ticket by e-mail.  Honestly, I can’t think of anything here they didn’t think of here.

From here: http://www.lucisferre.org/post/2009/08/20/Redmine-2b-IMAP-2b-Gmail-3d-Easy-ticket-submission-via-e-mail.aspx

Рубрики:project management, redmine, Software Метки:
  1. Murugesan R
    Апрель 13, 2012 в 6:46 дп | #1

    Thanks for the article. When i tried using your code it returns the following error
    «No connection could be made because the target machine actively refused it. — co
    nnect(2)»

    What might be the possible issue ?

    • Апрель 13, 2012 в 9:00 дп | #2

      It means that there are no TCP port in LISTENING mode on server that you tried to connect. Or firewall blocks such connections.

      I could give some advice if you describe your configuration in details.

  2. Murugesan R
    Апрель 13, 2012 в 12:14 пп | #3

    Thanks for your swift response !

    Now i am getting a different error, please refer the below.

    Redmine : BitNami Stack 1.3.2-1 (Windows)
    IMAP : My corporate email ID configured in MS Exchange server 2003
    Please note i am able to connect IMAP using command line. Please correct me if i am doing anything wrong.

    Below is the output

    C:\Documents and Settings\Administrator\Desktop>rem ##### GIT ENV #####

    C:\Documents and Settings\Administrator\Desktop>rem ##### SQLITE ENV #####

    C:\Documents and Settings\Administrator\Desktop>rem ##### IMAGEMAGICK ENV #####

    C:\Documents and Settings\Administrator\Desktop>set MAGICK_HOME=C:\Program Files
    \BitNami Redmine Stack/imagemagick

    C:\Documents and Settings\Administrator\Desktop>set MAGICK_CODER_MODULE_PATH=C:\
    Program Files\BitNami Redmine Stack/imagemagick\modules\coders

    C:\Documents and Settings\Administrator\Desktop>set MAGICK_CONFIGURE_PATH=C:\Pro
    gram Files\BitNami Redmine Stack/imagemagick\config

    C:\Documents and Settings\Administrator\Desktop>rem ##### RUBY ENV #####

    C:\Documents and Settings\Administrator\Desktop>set RUBYOPT=rubygems

    C:\Documents and Settings\Administrator\Desktop>rem ##### SUBVERSION ENV #####

    C:\Documents and Settings\Administrator\Desktop>rem ##### PHP ENV #####

    C:\Documents and Settings\Administrator\Desktop>set PHPRC=C:/Program Files/BitNa
    mi Redmine Stack/php

    C:\Documents and Settings\Administrator\Desktop>rem ##### MYSQL ENV #####

    C:\Documents and Settings\Administrator\Desktop>rem ##### APACHE ENV #####

    C:\Documents and Settings\Administrator\Desktop>cd C:\Program Files\BitNami Redm
    ine Stack/apps/redmine

    C:\Program Files\BitNami Redmine Stack\apps\redmine>CALL rake redmine:email:rece
    ive_imap RAILS_ENV=»production» host= port=143 ssl=0 username= password= project=Trend tracker=Task allow_overri
    de=project,tracker,priority
    rake aborted!
    SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown proto
    col

    Tasks: TOP => redmine:email:receive_imap
    (See full trace by running task with —trace)

  3. Murugesan R
    Апрель 13, 2012 в 12:15 пп | #4

    I ‘ve supplied host, username and password correctly in the above script

  4. iniy
    Февраль 23, 2013 в 12:28 пп | #5

    Many thanks! is there a way to autoassign the new ticket to an user?

  1. No trackbacks yet.

Добавить комментарий

Заполните поля или щелкните по значку, чтобы оставить свой комментарий:

Логотип WordPress.com

You are commenting using your WordPress.com account. Выход / Изменить )

Фотография Twitter

You are commenting using your Twitter account. Выход / Изменить )

Фотография Facebook

You are commenting using your Facebook account. Выход / Изменить )

Google+ photo

You are commenting using your Google+ account. Выход / Изменить )

Connecting to %s

Отслеживать

Get every new post delivered to your Inbox.

%d bloggers like this: