|Version 2 (modified by 14 years ago) ( diff ),|
- A way to receive emails on your Trac server
When I setup email2trac, I thought that this step was going to be the most difficult (mostly because I have no experience with email servers/services). Surprisingly, it is actually the easiest step. 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. 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-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 automaticly 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 or other mail server should automaticly 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 @ 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.
Thanks, Matthew, for your detailed response. It's amazing what a couple edits to the email2trac.py script can do! I'm happy to say that I've now got it all working smashingly.
A bit about my working solution:
- 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 and I like having to do a little Unix-y work. 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"
- 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://subtrac.sara.nl/oss/email2trac/wiki/Email2tracConfiguration for complete configuration instructions.
- 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. So, important config variables:
[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 . 11 so that you don't receive an error like "str object is not callable". See https://subtrac.sara.nl/oss/email2trac/ticket/34 for more information about the background of this one.
- 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
Thanks everyone for your responses and hopefully this can help someone in the future!