I've been meaning to put a full how-to together on getting Email2Trac
working in Windows (covering getting email to your server all the way
to putting tickets into Trac), but I haven't had the time. It looks
like there are many people struggling to this.
(Just as a disclaimer, I have hardly any Python experience, so my
changes probably aren't very flexible or cross-platform; I was just
trying to get stuff to work)
Platform: Windows Server 2003
Trac: trac 0.10.3
Python: Python 2.4
email2trac: email2trac 0.10
There are 3 pieces you need to effectively turn emails into Trac
1. A way to receive emails on your Trac server
2. A way to process or convert emails into Trac tickets (this would be
the email2trac python script)
3. A way to automate part (2.)
Here's what we use on Windows:
1. We use Windows' built-in SMTP server to deliver mail to our trac
server, but since you have that working, I won't elaborate.
2. Email2Trac isn't very Windows-friendly out of the box. I didn't so
much install it, as I ripped the files I wanted out of the source
tarball. Python code doesn't need to be compiled, so this works just
fine. Extract email2trac.tar.gz. Navigate into the resulting
email2trac-0.x folder and rename email2trac.py.in
to email2trac.py and
to delete_spam.py. Now copy email2trac.py,
delete_spam.py, and email2trac.conf to the location where you want to
run the script (I put mine in C:\python24\scripts).
For Email2Trac 0.10, I had to alter the script slightly to run. Edit
email2trac.py with your favorite editor (I use IDLE which comes with
the Windows Python package)
Comment out the syslog import (line 95 in 0.10); change:
(Note: It looks like this is handled in the latest version of
Next change the default configfile (line 984 in 0.10); change:
configfile = '@email2trac_conf@'
configfile = 'email2trac.conf'
Next, you'll want to edit email2trac.conf. Be sure to configure your
environment with Windows-style paths, and specify the temp directory.
(Used to extract attachments) Also, make sure the temp directory
exists. The top of mine looks like this:
(Note: we only use email2trac with one environment on our server
(despite the fact we run several))
You will likely want to make more changes to the config file to suit
your needs. See https://subtrac.sara.nl/oss/email2trac/wiki/Email2tracConfiguration
At this point, you should be able to push a single email into a ticket
from the command-line. Type:
cd C:\python24\Scripts (or wherever you put email2trac)
python email2trac.py < [C:\path\to\email.eml] (this depends on Python
being in your PATH)
3. We use Windows' Scheduled Tasks to automate email2trac. This works
in two parts: a batch file to run the script on a set of emails and a
scheduled task to run said batch file at regular intervals.
Create a new batch file in the same folder as your email2trac.py, ours
is C:\python24\Scripts\trac-email.bat. Edit it with notepad, insert
for %%f in (C:\Inetpub\mailroot\Drop\*.eml) do python email2trac.py < %
Now change "C:\Inetpub\mailroot\Drop\" to the location where your
emails are being delivered. You may also have to change "*.eml", if
they have different extensions.
Now go to Start->Control Panel->Scheduled Tasks->Add Scheduled Task.
This will start the Scheduled Task Wizard. Use "Browse..." to select
the batch file you just created as the program you wish to run. Give
the task a name you like, select "Daily". Put 12:00 AM as the start
time and perform "Every Day" with the current date as the start date.
For the user, I had problems using the unprivileged user that runs
tracd so I set myself as the user (definitely not secure; this is an
internal trac). Check "Open advanced properties..." and click
"Finish". The edit task dialog will pop up. Click "Schedule" tab,
then "Advanced...". Check "Repeat task", set "Every:" to 10 minutes
(or your desired interval). Set "Duration:" to 24 hours. Click "OK",
"OK" to close the dialogs. You can now test your task by right-
clicking and selecting "Run". You should see a command-line window
Hopefully this is helpful to you; I set this up a while ago, so I may
be a little rusty on the important details. And hopefully some better
Windows instructions appear on the email2trac site.
- Matthew Carlson