|Version 5 (modified by 7 years ago) ( diff ),|
Running Email2trac On Windows
This page describes the steps to take to set up Email2trac on a Windows server running Trac.
When setting up email2trac, the trick is to 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 an email server hands off email between the two services. In a way, email2trac performs the distribution functions normally handled by POP.
Install the SMTP service via Windows Components. Go to your Control Panel, then "Add or Remove Programs".
Click "Add/ Remove Windows Components" in the left-hand bar. Use the "Details…" button to drill-in to Application Server → Internet Information Services (IIS) → SMTP Service. Check the box next to SMTP Service, click "OK", "OK", "Next", "Finish".
I don't remember if I had to configure anything for SMTP (If I did, it wasn't much). You find configuration at Start → Control Panel → Admistrative Tools → Internet Information Services (IIS) Manager. I have "Default SMTP Virtual Server" listed, with a Domain Name of "trac-server.domain.com" with Type "Local (Default)". I believe the installation automatically creates the drop folder at C:\Inetpub\mailroot\Drop. You can see that my email2trac batch script picks up .eml files from that location.
To actually get emails to the server, you have to use the address "anyth...@…". Your Exchange Server or other mail server should automatically forward the emails to the server. If you want to use a different form, you will likely have to configure your mail server to forward the mail. The name before the at-sign (@) can be anything. POP service usually uses this, SMTP and email2trac ignore it. A possible enhancement to email2trac would be to use the address to identify the destination environment for the ticket.
The working solution:
1. Fetchmail — Retrieves email from the Exchange server. I have it set up to automatically feed retrieved messages to the script, so I don't need an additional script to do this. At some point I might want to change this piece of the equation to get rid of the overhead of the Cygwin component, but it's working. Relevant .fetchmailrc file: poll mail.domain.com with proto IMAP, auth ntlm user "t...@…" with password "xxx" is trac here options keep mda "C:/python25/python.exe C:/projects/email2trac/email2trac.py"
2. email2trac script — As can be seen in the above .fetchmailrc file, I put my script and related files in the path C:/projects/email2trac. I made the changes to email2trac.py that Matthew mentions along with a couple changes specific to my solution.
- Config file variable — Since I'm calling the script from fetchmail, I needed to specify the full path to the config file in the email2trac.py script, i.e. C:/projects/email2trac/email2trac.conf
- Signature stripping — I found that the signature stripping done in the script when the strip_signature config variable was set didn't work correctly for the format of our emails so I made a slight edit to the script. In the section of the script that defines useful mail constants (around line 141), I added the variable self.get_signature_match = '—-'. Then in the strip_signature method (around line 728) I replaced the line "if line == '— ':" with "if line.startswith(self.get_signature_match):". This resulted in the successful stripping of most signatures as well as old original message info I didn't want to get added on each response.
Note: See https://oss.trac.surfsara.nl/email2trac/wiki/Email2tracConfiguration for complete configuration instructions.
3. email2trac.conf — Matthew covered this, but might as well mention it again along with a caveat I found related to using email2trac with Trac 0.11. The important configuration variables are:
[DEFAULT] project: C:\projects\trac\environmentname tmpdir: C:\tmp ticket_update: 1 strip_signature: 1 python_egg_cache: C:\Python25\Scripts trac_version: 0.11
Obviously, if you don't wish to strip signatures, you would set that to 0. 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 https://oss.trac.surfsara.nl/email2trac/ticket/34 for more information about the background of this one.
4. Making it all work together — I created a simple batch file that is run by Scheduled Tasks. All it does is run fetchmail:
C:\cygwin\bin\fetchmail -v --fetchmailrc C:/cygwin/path/to/fetchmailrc --logfile c:/projects/email2trac/fetchmail.log