Monday, September 23, 2013

Redmine, procmail + rdm-mailhandler.rb howto

This is a quick solution on how to allow creation of new tickets in Redmine using Procmail and rdm-mailhandler.rb (provided by Redmine). Redmine's Wiki has a good page about processing incoming emails http://www.redmine.org/projects/redmine/wiki/RedmineReceivingEmails, but it lacks procmail's actual rules.

1. Configure Postfix to deliver local to procmail:

root@host# tail /etc/postfix/main.cf
...
virtual_alias_maps = hash:/etc/postfix/virtual
mailbox_command = /usr/bin/procmail


2. Configure aliases:

root@host# cat /etc/postfix/virtual
...
@redmine.yourhost.com redmine
...


3. Update aliases

root@host# newaliases


3. In redmine's home dir put the following procmail.rc:

redmine@host:~$ cat ~/.procmailrc
VERBOSE=on

:0:
* ^TO_\s*[^@]+@redmine\.yourhost\.com
* ^TO_\s*\/[^@]+
| /var/www/redmine.yourhost.com/rdm-mailhandler.rb --url https://redmine.yourhost.com/ --key XXXXXXXXXXXXXXXXXXXXX --project $MATCH --tracker bug --allow-override tracker,priority --unknown-user create --no-permission-check --no-account-notice


Now to create new issue in redmine, you can send an email to identifier@redmine.yourhost.com, where `identifier` is redmine's project identifier, just do not forget to replace yourhost.com with your actual hostname.




1 comment: