wiki:EmailtoTracScript

Version 51 (modified by bas, 8 years ago) (diff)

--

Convert email to trac tickets

Description

email2trac utilities

This is a release of the SARA package email2trac that contains utilities that we use to convert emails to trac tickets. The initial setup was made by Daniel Lundin from Edgewall Software. SARA has extend the initial setup, with the following extensions:

  • HTML messages
  • Attachments
  • Use commandline options
  • Use config file to change the behaviour of the email2trac.py program
  • Some unicode support for special characters in the headers of an email message

See INSTALL for the how to setup the utilities

Comments or Suggestions mail them to:

  • Bas van der Vlies, more info about SARA
  • Walter de Jong

Contributor: (0.9 port + implemented some new features)

  • Michel Jouvin

Bugs/Feature Requests

Existing bugs and feature requests for EmailtoTracScript are here.

If you have any issues, create a new ticket.

Download

Download the latest stable source from ftp://ftp.sara.nl/pub/outgoing/email2trac.tar.gz.

Source

You can check out EmailtoTracScript from here using Subversion, or browse the source with Trac.

Installation and Configuration

The email2trac package contains the following utilities:

email2trac.py
Converts an email to ticket. Reads a config file email2trac.conf
run_email2trac.c
Suid program that changes the MTA-user to the TRAC-user so that we can save attachments
delete_spam.py
A small program that deletes the SPAM tickets from the database
email2trac.conf::

Is read by email2trac.py to set the various options. This are the options:

NAME VALUE Explanation
[!DEFAULT] REQUIRED
project: /data/trac/jouvin REQUIRED
debug: 1 OPTIONAL, if set print some DEBUG info
spam_level: 4 OPTIONAL, if set check for SPAM mail
drop_spam: 0 OPTIONAL:, if set then reject mail marked as SPAM
reply_all: 1 OPTIONAL, if set then put all CC-addresses in ticket CC-field
umask: 022 OPTIONAL, Use this umask for saving attachments
mailto_link: 1 OPTIONAL, if set then [mailto:CC] in description
mailto_cc: ticket@… OPTIONAL, Use ths address as CC in mailto line
ticket_update: 1 OPTIONAL, if set then check if this is an update for a ticket
email_header: 1 OPTIONAL, if set then show TO/CC fields in description
trac_version: 0.9 OPTIONAL. if set then use this as version number, default 0.9
alternate_notify_template a_ticket.css OPTIONAL if set then use this style sheet for notify
enable_syslog 1 OPTIONAL, if set log errors to syslog, note they are not mailed back to the reporter
[bas] OPTIONAL project declaration, also set project and use --project option
project: /data/trac/bas
spam_level: 2 Override DEFAULT spam_level, can also be done for other options

Installation and Configuration

First build, install email2trac :

Configure

  • ./configure (see --help)
    default values for:
       prefix=/usr/local        --> --prefix=<path>
       exec_prefix=$prefix/bin  --> --exec_prefix=<path>
       sysconfdir=$prefix/etc   --> --sysconfdir=<path>
       MTA_USER=nobody          --> --with-mta_user=<name>
       TRAC_USER=www-data       --> --with-trac_user=<name>
    
  • make
  • make install
  • First install copy emailtrac.conf to $sysconfdir

Debian package

  • debian/rules binary
  • dpkg -i ../email2trac_<version>.deb
  • cp email2trac.conf /etc

RPM package

  • cp email2trac.tar.gz /usr/src/redhat/SOURCES
  • rpmbuild -ba email2trac.spec

After installation, edit email2trac.conf for your site. Most important parameter is project, see above

If you have enabled 'ticket_update' in email2trac.conf then you have to choose one of this options to make it work:

  • Configure trac notification, eg:
          (ticket address: ticket@test.nl)
          [notification]
          smtp_enabled = true
          smtp_always_cc = test@test.nl
          smtp_server = localhost
          smtp_from =  ticket@test.nl
          always_notify_reporter = true
    
  • Use the mailto_cc in email2trac.conf if you want to send an email to the ticket email address.

Usage

It depends on your MTA how the setup is. For Sendmail and Postfix, the procedure is the same :

  • Edit your alias definition file (default : /etc/aliases for Postfix, /etc/mail/aliases for Sendmail) and add one line per project/component you want to allow ticket submission from email to. For each alias, you can specify option --project. This option selects a configuration stanza in the config file and --component to specify a component other than the default component for the project. Line must have the following format :
         tracproj: |/usr/bin/run_email2trac [--project=<name>] [--component=<component>]
    
  • Update your alias database with command newaliases
  • Test with a command like :
         mail tracproj < msg.txt 
    
  • if mail fails you can also check if it is an email setup error or a trac-setup error, test it with the following command:
    email2trac --project=tracproj < msg.txt 
    if this is oke then it is an email setup error
    

Note for postfix

run_email2trac is totally unnecessary for Postfix. You can run a delivery command as any user just by placing the aliases in a separate file and chowning that aliases file to the user you want the delivery to run as. Then you run postalias /path/to/aliases, which will create /path/to/aliases.db, and you then just add hash:/path/to/aliases to the alias_maps config variable in main.cf. The only caveat is that the user who owns the separate aliases file needs to have write perms to the directory that it's stored in (which rules out putting it in /etc/postfix unless you're nuts) -- mpalmer@….

Note for Sendmail

This is a message from emailtotrac tickets archive:

Sendmail limits the executables that can be run via aliases to those in a
special directory, and runs them using a restricted shell called smrsh.
On RH, the default location for the allowed programs is /etc/smrsh.

I tried both a link in that dir to the run_email2trac file and a little
shell script that simply calls run_email2trac and passes the params. Both
should work, but neither did yet. Majordomo works the same way, and it
set up on the machine already so I'll check on that later today.

I found a pretty good walk-through of the problem/solution at
http://archives.free.net.ph/message/20030605.105120.74c3bfa8.html

Well, I was in fact doing the right thing. Here's all the steps to follow
post make install

ln -s /usr/local/bin/run_email2trac /etc/smrsh/run_email2trac

in aliases use:

"|run_email2trac -project=bas"

Note: Include the quotes, they are necessary. That got me past the
sendmail problem. No ticket appeared in the project, but I'll look into
that next. Is there a log generated anywhere?

Author/Contributors

Author: bas, Walter de Jong
Contributors: Michel Jouvin, Kilian Cavalotti

TagIt(script,bas,0.8,0.9,0.10)?