40 | | == Source == |
41 | | |
42 | | You can check out EmailtoTracScript from [http://trac-hacks.org/svn/emailtotracscript here] using Subversion, or [source:emailtotracscript browse the source] with Trac. |
43 | | |
44 | | == Installation and Configuration == |
45 | | |
46 | | The email2trac package contains the following utilities: |
47 | | '''email2trac.py''':: |
48 | | Converts an email to ticket. Reads a config file email2trac.conf |
49 | | '''run_email2trac.c''':: |
50 | | Suid program that changes the MTA-user to the TRAC-user so that we can |
51 | | save attachments |
52 | | '''delete_spam.py''':: |
53 | | A small program that deletes the SPAM tickets from the database |
54 | | '''email2trac.conf''':: |
55 | | Is read by email2trac.py to set the various options. These are the options: |
56 | | |
57 | | || NAME || VALUE || Explanation || |
58 | | || [!DEFAULT] || || REQUIRED || |
59 | | || project: || /data/trac/jouvin || REQUIRED || |
60 | | || debug: || 1 || OPTIONAL, if set print some DEBUG info || |
61 | | || spam_level: || 4 || OPTIONAL, if set check for SPAM mail || |
62 | | || drop_spam: || 0 || OPTIONAL:, if set then reject mail marked as SPAM || |
63 | | || reply_all: || 1 || OPTIONAL, if set then put all CC-addresses in ticket CC-field || |
64 | | || umask: || 022 || OPTIONAL, Use this umask for saving attachments || |
65 | | || mailto_link: || 1 || OPTIONAL, if set then {{{[mailto:CC]}}} in description || |
66 | | || mailto_cc: || ticket@test.nl || OPTIONAL, Use ths address as CC in mailto line || |
67 | | || ticket_update: || 1 || OPTIONAL, if set then check if this is an update for a ticket || |
68 | | || email_header: || 1 || OPTIONAL, if set then show TO/CC fields in description|| |
69 | | || trac_version: || 0.9 || OPTIONAL. if set then use this as version number, default 0.9 |
70 | | || alternate_notify_template || a_ticket.css || OPTIONAL if set then use this style sheet for notify || |
71 | | || enable_syslog || 1 || OPTIONAL, if set log errors to syslog, note they are ''not'' mailed back to the reporter || |
72 | | |
73 | | || || || |
74 | | || || || |
75 | | || [bas] || || OPTIONAL project declaration, also set project and use --project option || |
76 | | || project:|| /data/trac/bas || || |
77 | | || spam_level:|| 2 || Override DEFAULT spam_level, can also be done for other options || |
78 | | |
79 | | |
80 | | === Installation and Configuration === |
81 | | |
82 | | First build, install email2trac : |
83 | | |
84 | | ==== Configure ==== |
85 | | * ./configure (see --help) |
86 | | {{{ |
87 | | default values for: |
88 | | prefix=/usr/local --> --prefix=<path> |
89 | | exec_prefix=$prefix/bin --> --exec_prefix=<path> |
90 | | sysconfdir=$prefix/etc --> --sysconfdir=<path> |
91 | | MTA_USER=nobody --> --with-mta_user=<name> |
92 | | TRAC_USER=www-data --> --with-trac_user=<name> |
93 | | }}} |
94 | | * make |
95 | | * make install |
96 | | * On the first install, copy {{{email2trac.conf}}} to {{{$sysconfdir}}} |
97 | | |
98 | | ==== Debian package ==== |
99 | | * debian/rules binary |
100 | | * dpkg -i ../email2trac_<version>.deb |
101 | | * cp email2trac.conf /etc |
102 | | |
103 | | ==== RPM package ==== |
104 | | * cp email2trac.tar.gz /usr/src/redhat/SOURCES |
105 | | * rpmbuild -ba email2trac.spec |
106 | | |
107 | | |
108 | | After installation, edit email2trac.conf for your site. Most important |
109 | | parameter is project, see above |
110 | | |
111 | | If you have enabled 'ticket_update' in email2trac.conf then you have |
112 | | to choose one of the following options to make it work: |
113 | | * Configure trac notification, eg: |
114 | | {{{ |
115 | | (ticket address: ticket@test.nl) |
116 | | [notification] |
117 | | smtp_enabled = true |
118 | | smtp_always_cc = test@test.nl |
119 | | smtp_server = localhost |
120 | | smtp_from = ticket@test.nl |
121 | | always_notify_reporter = true |
122 | | }}} |
123 | | * Use the mailto_cc in email2trac.conf if you want to send an email to the ticket email address. |
124 | | |
125 | | |
126 | | == Usage == |
127 | | |
128 | | It depends on your MTA how the setup is. For Sendmail and Postfix, the procedure is the same : |
129 | | * Edit your alias definition file (default : /etc/aliases for Postfix, |
130 | | /etc/mail/aliases for Sendmail) and add one line per project/component you |
131 | | want to allow ticket submission from email to. For each alias, you can |
132 | | specify option --project. This option selects a configuration stanza in the |
133 | | config file and ''--component'' to specify a component other than the |
134 | | default component for the project. Line must have the following format : |
135 | | {{{ |
136 | | tracproj: |/usr/bin/run_email2trac [--project=<name>] [--component=<component>] |
137 | | }}} |
138 | | |
139 | | * Update your alias database with command ''newaliases'' |
140 | | * Test with a command like : |
141 | | {{{ |
142 | | mail tracproj < msg.txt |
143 | | }}} |
144 | | * 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: |
145 | | {{{ |
146 | | email2trac --project=tracproj < msg.txt |
147 | | if this is okay then it is an email setup error |
148 | | }}} |
149 | | |
150 | | === Note for postfix === |
151 | | |
152 | | {{{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 {{{chown}}}ing 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}}}. |
153 | | |
154 | | 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) |
155 | | -- mpalmer@hezmatt.org. |
156 | | |
157 | | === Note for Sendmail === |
158 | | This is a message from emailtotrac tickets archive: |
159 | | {{{ |
160 | | Sendmail limits the executables that can be run via aliases to those in a |
161 | | special directory, and runs them using a restricted shell called smrsh. |
162 | | On RH, the default location for the allowed programs is /etc/smrsh. |
163 | | |
164 | | I tried both a link in that dir to the run_email2trac file and a little |
165 | | shell script that simply calls run_email2trac and passes the params. Both |
166 | | should work, but neither did yet. Majordomo works the same way, and it |
167 | | set up on the machine already so I'll check on that later today. |
168 | | |
169 | | I found a pretty good walk-through of the problem/solution at |
170 | | http://archives.free.net.ph/message/20030605.105120.74c3bfa8.html |
171 | | |
172 | | Well, I was in fact doing the right thing. Here's all the steps to follow |
173 | | post make install |
174 | | |
175 | | ln -s /usr/local/bin/run_email2trac /etc/smrsh/run_email2trac |
176 | | |
177 | | in aliases use: |
178 | | |
179 | | "|run_email2trac -project=bas" |
180 | | |
181 | | Note: Include the quotes, they are necessary. That got me past the |
182 | | sendmail problem. No ticket appeared in the project, but I'll look into |
183 | | that next. Is there a log generated anywhere? |
184 | | }}} |
185 | | |
186 | | === Note for exim === |
187 | | |
188 | | As with Postfix, {{{run_email2trac}}} is unnecessary. Instead of editing the {{{/etc/aliases}}} file, one must create a router and a transport. My own Debian-compatible configs follow. Slight modification should make them usable for you. |
189 | | {{{ |
190 | | theblackbox:/etc/exim4/conf.d# cat router/101_exim4-config_trac_gw |
191 | | trac_router: |
192 | | driver = accept |
193 | | require_files = /usr/local/bin/email2trac |
194 | | local_parts = support |
195 | | transport = trac_transport |
196 | | |
197 | | theblackbox:/etc/exim4/conf.d# cat transport/30_exim4-config_trac |
198 | | trac_transport: |
199 | | driver = pipe |
200 | | command = /usr/local/bin/email2trac |
201 | | current_directory = /tmp |
202 | | home_directory = /tmp |
203 | | user = www-data |
204 | | group = www-data |
205 | | theblackbox:/etc/exim4/conf.d# |
206 | | }}} |
207 | | -- alexander (here insert a squiggly 'at' thing) garden.msbx.net |
208 | | |
209 | | == Author/Contributors == |
210 | | |
211 | | '''Author:''' [wiki:bas], [mailto:walter@sara.nl Walter de Jong][[BR]] |
212 | | '''Contributors:''' Michel Jouvin, Kilian Cavalotti |