Redmine Cookbook
上QQ阅读APP看书,第一时间看更新

Interacting with Redmine only through e-mail

If your company is large or for some other reason you need to have some users interact with the Redmine system only through e-mail, this feature is very useful. It enables your users to either create new tasks/issues by e-mail or respond to existing issues by replying to e-mail messages that are emitted by Redmine. As such, it enables all kinds of logical organizations of your business. For example, you can have users submitting support requests by e-mail, and operators processing their requests through Redmine, which is extremely useful in various kinds of helpdesk departments.

Getting ready

The first thing that you need to do is open an account for Redmine on your e-mail server. It can be redmine@yourdomain.com or any other username, just make sure it's the same username that Redmine is using when sending e-mails. It does not have to be the same, but it's preferred that it be the same to avoid ambiguities that different e-mail accounts can cause.

Once your Redmine account is opened on your e-mail server, rename the /config/configuration.yml.example as /config/configuration.yml and edit it according to the settings for the account that you just created for Redmine. You can test these settings through the Administration menu. If you navigate to the Administration | Settings | E-mail notifications tab, there is a Send test e-mail hyperlink at the bottom right, as displayed in the following screenshot:

Once you have made sure that e-mail emission is working, you can proceed with configuring incoming e-mail interaction.

How to do it…

Redmine can receive incoming e-mails in two different concepts or three different settings. Basically, it is a server push or client pull. This recipe explains the client pull method because not all users have the luxury or knowledge to tamper with Mail Transfer Agent (MTA) software.

Linux users

The steps that Linux users should follow are as follows:

  1. Create a shell script file, named fetch_e-mail.sh, in the /extra subfolder of your Redmine installation, with the following content:
    #!/bin/bash
    cd /var/www/redmine
    rake redmine:e-mail:receive_pop3 RAILS_ENV="production" host=your_e-mail_server username=redmine password=redmine
    
  2. Replace the host, username, and password variables with the ones that fit your e-mail server and Redmine account credentials.
  3. Log in or sudo to the user under which Redmine is running, and create a Unix CRON (Command Run On) job by typing the following in shell:
    crontab –e
    

    Then, enter the following contents:

    5 * * * * /var/www/redmine/extra/fetch_e-mail.sh
    

    Tip

    Keep in mind to replace /var/www/redmine in steps 1 and 3 with a path to your redmine installation root folder if it is different, for example like /home/my_user/redmine

Windows users

The steps that Windows users should follow are as follows:

  1. Create a batch file, called fetch_e-mail.bat, inside the /extra directory of your Redmine installation, with the following content:
    rake redmine:e-mail:receive_pop3 RAILS_ENV="production" host=your_e-mail_server username=redmine password=redmine
  2. Replace the host, username, and password variables with the ones that fit your e-mail server and Redmine account credentials.
  3. Start a Task scheduler, hold the Windows key, then press R, type Taskschd.msc on the right side, and choose Create Task. Type a name for your task, optionally a Description, and choose either Network service or Local service as a user account under which to run the task. Also, tick the bottom Hidden checkbox:
  4. Next, on the Triggers tab, make the task run every 15 minutes, or 5 if you need it more frequently:
  5. Finally, on the Actions tab, click Browse, and find the .bat file that we created. On the Start in section, type the root folder of your Redmine installation:

How it works…

This recipe is implementing a POP3 client pull method. Basically, Redmine is doing what most desktop e-mail clients do: it checks for incoming e-mails every 15 minutes. What we have done for both Windows and Linux is create a shell script, and add a job to the system scheduler to be run in the given time period. In both cases, we are running a rake task with POP3 access parameters to your server, which parses incoming e-mails, and if properly parsed, it creates new Redmine issues or adds comments to existing ones.

There's more…

Under the Incoming e-mails tab in Administration | Settings, there are additional options available, which let you truncate e-mails after certain lines. For example, if your company uses signatures, or you need to truncate the quoted part when replying to e-mails, then just add the delimiter that your company's e-mail client is using, and the reply part won't be visible in issue updates:

The Exclude attachments by name feature lets you exclude attachments, such as VCF (contact files), or signatures/logos, to be added to your issues when e-mails are parsed.

See also

Redmine's official incoming e-mail configuration page can be found at the following location:

http://www.redmine.org/projects/redmine/wiki/RedmineReceivingEmails.