Version 10 (modified by Matthew Carlson, 16 years ago) (diff)

Added my parts from the Trac User discussion

Email2trac on Windows

Using email2trac on Windows requires three components:

1 A way to receive/gather email 2 The email2trac script 3 a script or batch file that will schedule email2trac to process emails (i.e. automate the process).

Email component

Options for email component depend on whether Trac is installed on a server that already handles email.

  • Trac server doesn't handle email: Two common options are to install the built-in SMTP server or to use an email client such as Fetchmail.
  • Trac server handles email (SMTP already in use): Depending on email software, you may be able to configure the server to drop emails in a folder. Otherwise, use an email client such as Fetchmail.
  • Trac server runs Microsoft Exchange: Exchange has no easy option to drop emails in a folder, you must use an email client such as Fetchmail.

Built-in Windows SMTP server

Install the SMTP server, but not the POP server, so that emails are received and left as files in the "drop" folder. This is the way the email server hands off email between the two services. In a way, email2trac performs the distribution functions normally handled by POP. To install the SMTP service via Windows Components:

  • Open Add/Remove? Programs (Start->Control Panel->Add or Remove Programs)
  • Click Add/Remove? Windows Components in the left-hand bar. Use the "Details..." button to drill into Application Server->Internet Information Services (IIS)->SMTP Service.
  • Check the box next to SMTP Service, click "OK", "OK", "Next", "Finish".

The SMTP Service should be configured to receive emails out of the box. If you have problems, check that the service is running (Start->Control Panel->Admistrative Tools->Services), and set any software firewalls to allow incoming connections to port 25. Additional configuration can be done using the IIS Manager (Start->Control Panel->Admistrative Tools->Internet Information Services (IIS) Manager).

Default configuration of "Default SMTP Virtual Server":

  • Domains
    • Domain Name:
    • Type: Local (Default)
    • Drop folder: C:\Inetpub\mailroot\Drop
  • Many more options under "Default SMTP Virtual Server", right-click, "Properties".

In this configuration, anything sent to an email address with the trac-server subdomain (xxx@…) should be automatically forwarded from the email server to the local SMTP server. If you would like your Trac email address to be formatted differently, you will need to configure your main email server to forward mail sent to your designated Trac email address to the trac-server subdomain. You may need to configure your main email server if it does not properly forward emails to your Trac server.


Fetchmail requires Cygwin, a Linux-emulation layer, to operate on Windows. Cygwin installation is straight forward as is adding the fetchmail package, but Lifehacker's Introduction to Cygwin and Fetchmail articles are very helpful tutorials for getting Cygwin installed and adding the fetchmail package.

Fetchmail options can be set in the command line or using a .fetchmailrc configuration file, .fetchmailrc. Sample .fetchmailrc file:

poll with proto IMAP, auth ntlm user ""
with password "xxx" is trac here options keep
mda "C:/python25/python.exe C:/projects/email2trac/"

.fetchmailrc should be put in a location accessible to fetchmail, such as /home/trac (Cygwin path).

Note that in this setup, email2trac acts as the MDA (or MTA) and automatically processes mail as it is retrieved.

Email2trac Script Setup

Obtain a copy of the script, either by downloading the latest stable source or getting the latest trunk or tagged version. Unlike in a *nix environment, email2trac on Windows does not have to be built or packaged to work. Only the following files are needed:

  • email2trac.conf

Put these files in the directory of your choice, e.g. C:/projects/email2trac. Rename to and to A couple edits are necessary for to work in the Windows environment.

  1. Specify the email2trac configuration file path (around line 1060 in version 0.13). The specificity of the path required depends on how you are retrieving emails -- if you are using fetchmail, you will need to specify the complete path (i.e. C:/projects/email2trac/email2trac.conf).
     #configfile = '@email2trac_conf@'
     configfile = 'email2trac.conf'
  1. (For versions prior to 0.13 only) Comment out the syslog import (around line 95 in version 0.10).
    #import syslog 

Email2trac Configuration

There are many configuration options for email2trac, but the following are necessary for email2trac to work properly.

 project: C:\projects\trac\environmentname
 tmpdir: C:\tmp
 ticket_update: 1
 python_egg_cache: C:\Python25\Scripts
 trac_version: 0.11

The tmpdir can be anything, but should already exist; be sure the user who will run email2trac has write permissions to this directory. The trac_version variable is important if you're running trac 0.11 so that you don't receive an error like "str object is not callable". See for more information about the background of this one.

Process Automation

Use Scheduled Tasks to automate email2trac. This works in two parts: a batch file (dependent on email setup) and a scheduled task to run said batch file at regular intervals.

Batch for Built-in Windows SMTP server

Create a batch file (e.g. C:/projects/email2trac/email2trac.bat) to process emails in the "drop" folder.

@echo off

for %%f in (C:\Inetpub\mailroot\Drop\*.eml) do python < %%f
del C:\Inetpub\mailroot\Drop\*.eml

Change the paths as necessary to reflect your setup. This version assumes is in the same directory as the batch file and python is in your PATH.

Batch for Fetchmail

Create a batch file (e.g. C:/projects/email2trac/email2trac.bat) that calls fetchmail, specifying the path to the fetchmail configuration file and, optionally, a logfile to log the fetchmail process.

C:\cygwin\bin\fetchmail -v --fetchmailrc C:/cygwin/path/to/fetchmailrc
--logfile c:/projects/email2trac/fetchmail.log

Scheduled Task

The Scheduled Task Wizard is pretty straightforward, but the repetition settings are pretty buried. To create the Scheduled Task:

1 Start the Scheduled Task Wizard(Start > Control Panel > Scheduled Tasks > Add Scheduled Task). Click "Next >". 2 Use "Browse..." to select the batch file you just created as the program you wish to run. 3 Give the task a name, select "Daily". Click "Next >". 4 Set "Start time:" to 12:00 AM, "Perform this task:" to "Every Day", "Start date:" to current date. Click "Next >". 5 Enter a user. I had problems running the task as the unprivileged user that runs tracd, so I set myself as the user (definitely not as secure, but our Trac is on our local intranet). Click "Next >". 6 Check "Open advanced properties..." and click "Finish". The edit task dialog will pop up. 7 Click "Schedule" tab, then "Advanced...". 8 Check "Repeat task", set "Every:" to your desired interval. Set "Duration:" to 24 hours. 9 Click "OK", "OK" to close the dialogs.

Test your task by right-clicking it and selecting "Run". You should see a command-line window briefly appear running your batch file. Check your Trac to make sure you have new tickets.

Note: This content came from a discussion on the Trac Users Group. Also, see Matthew's summary. A big thanks to Matthew Carlson for his detailed help.

Authored by Nicole Swan (nicole DOT swan AT and Matthew Carlson (calrsom AT