Version 53 (modified by anonymous, 7 years ago) (diff)


Mail server configuration

It depends on your Mail Transfer Agent (MTA) how the setup.

email2trac/run_email2trac command line options

email2trac can handle several command line options. Here is a short description of the command line options:

-A, --agilo::

Enable the Agilo Ticket module, see Agilo for trac.

-d, --debug::

Enable debug mode, all output is also send to the terminal and the parsed message is saved in TMPDIR.

-E, --virtualenv <path>::

Sets/override the path where the trac virtual installation environment can be found.

-f, --file <configuration file::

Use an alternate configuration file


Do not do anything, only show the commands.

-p,--project <name>::

This option selects a configuration stanza in the email2trac.conf

-t, --ticket_prefix <name>::

Default values for ticket fields


Increase log level from error to info. The output is dependent on the log settings specified in email2trac.conf

run_email2trac can handle all email2trac options plus some extra:

-e, --eggcache::

Set the environment for the python egg cache directory. This must be writable by the trac user.


The procedure is:

  • Edit your alias definition file (default : /etc/aliases) for Postfix and add one line per project you want to allow ticket submission from email to.
         tracproj: "|/usr/bin/email2trac <see command line options>
  • Update your alias database with command newaliases
  • Hint: Please note that postfix seemingly runs commands from the alias definition file as user "nobody", even if the rest of it is running as user "postfix". So please assure that the MTA_USER is set to nobody, not to postfix!
  • Hint: Set the environment for the python egg cache directory in the email2trac.conf. The directory must be writable by the trac user e.g /tmp.

Note for postfix

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 chowning 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

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) -- mpalmer@….

Calling email2trac in /etc/aliases for MTA_USER=nobody and TRAC_USER=apache on CentOS 6.4 gave me an error. Following the suggestion by mpalmer works. Use postfix reload to quickly reload the configuration file. I also had to relax SELinux with setenforce 0 to have permission to run the script. -- ybendana

I followed the above instructions, but still had an error

TracError: The user nobody requires read _and_ write permissions to the 
database file /var/tracprj/db/trac.db and the directory it is located in.

I then added to /etc/sudoers

nobody ALL=(apache) NOPASSWD: /usr/local/bin/email2trac

And changed the line my postfix aliases file to

ticket: "| sudo -u apache /usr/local/bin/email2trac

ran postalias and postfix reload, and now I get a new error

email2trac tracprj: File "/usr/lib/python2.6/site-packages/Trac-1.0.2-py2.6.egg/trac/db/", line 156, in __exit__#012 self.db.commit()
email2trac tracprj: OperationalError: disk I/O error

CentOS6.2 with Trac 1.0.2


The procedure is:

  • Edit your alias definition file (default : /etc/mail/aliases) for Sendmail and add one line per project you want to allow ticket submission from email to.
         tracproj: "|/usr/bin/run_email2trac <command line options>
  • Update your alias database with command newaliases

Note for Sendmail

  1. Your sendmail might look like it's running as root (using 'ps') but you should use the "id trick" detailed at

to double-check. You may well see that sendmail actually runs as user 'daemon' so you need to re-run configure and rebuild. This is probably your problem if you see "unknown mailer error 254".

  1. This is a message from emailtotrac tickets archive:
Sendmail limits the executable that can be run via aliases to those in a
special directory, and runs them using a restricted shell called smrsh.
On RH, the default location for the allowed programs is /etc/smrsh.

I tried both a link in that dir to the run_email2trac file and a little
shell script that simply calls run_email2trac and passes the params. Both
should work, but neither did yet. Majordomo works the same way, and it
set up on the machine already so I'll check on that later today.

I found a pretty good walk-through of the problem/solution at

Well, I was in fact doing the right thing. Here's all the steps to follow
post make install

ln -s /usr/local/bin/run_email2trac /etc/smrsh/run_email2trac

in aliases use:

"|run_email2trac -project bas"

Note: Include the quotes, they are necessary. That got me past the
sendmail problem. No ticket appeared in the project, but I'll look into
that next. Is there a log generated anywhere?

Exim Setup

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.

theblackbox:/etc/exim4/conf.d# cat router/101_exim4-config_trac_gw
  driver = accept
  require_files = /usr/local/bin/email2trac
  local_parts = support
  transport = trac_transport

theblackbox:/etc/exim4/conf.d# cat transport/30_exim4-config_trac
  driver = pipe
  command = /usr/local/bin/email2trac
  current_directory = /tmp
  home_directory =  /tmp
  user = www-data
  group = www-data

-- alexander (here insert a squiggly 'at' thing)

Fetchmail Setup

For those of you that installed the mail server on a different server than the subversion/trac server, you might want to use fetchmail instead. I have succeeded by simply set the mda value in /etc/fetchmailrc to run_email2trac

poll <mail_server_address> with proto IMAP|POP3 and options no dns
user '<username>' there with password '<password>' is '<username_on_machine_that_runs_fetchmail>' here options ssl
mda "/usr/local/bin/run_email2trac"

you need to specify mta_user to fetchmail user when you configure email2trac previously.

Using procmail with fetchmail & email2trac

You may want to filter bounced messages from ever getting to email2trac, otherwise you can end up in an infite loop. Simply change your mda in your .fetchmailrc to procmail and create a .procmailrc like this:

MAILDIR=$HOME/Mail      #you'd better make sure it exists
DEFAULT=$MAILDIR/mbox      #completely optional
LOGFILE=$MAILDIR/from      #recommended

:0 h b
* !^X-Loop: your.email2trac@emai.address
| /usr/local/bin/run_email2trac

Now only messages that aren't from a daemon or bounced will make it to email2trac.

Qmail Setup

qmail has .qmail files for each user. /var/qmail/mailnames/domain/ will have a list of user directories, each of which contains a .qmail file. In the .qmail file for your trac user, insert the following:

|preline "/usr/local/bin/run_email2trac <command line options>

Preline is a qmail helper that appends proper email headers to emails, in order that "traditional" filtering programs can deal with qmail emails.

jason hat (-h)

On some qmail installation this won't work 'cause run_email2trac isn't able to change uid to the trac-user. So, first of all there should be a sudoers for the user calling it:

popuser ALL = (wwwrun)NOPASSWD: /usr/local/bin/run_email2trac

Change popuser to the user the qmail helper runs as.

|PYTHON_EGG_CACHE=<path-to-dir> /var/qmail/bin/preline /usr/bin/sudo -u wwwrun /usr/local/bin/run_email2trac

Of course don't forget required --project option :). The PYTHON_EGG_CACHE variable should point to a area the trac user may write. If you don't need it, remove this.

ral at alwins-world dot de

Using Separate Virtual Domain

This setup example, adds a new virtual domain in the qmail configuration that will be the host email domain for all Trac environments in a uniform multi trac setup. The local usernames in email addresses will be Trac environment UNIX names, but each Trac environment will need a separate .qmail-<trac-env> file calling email2trac with the correspondent --project=<trac-env> option.

With this setup you will benefit from the use of the parentdir configuration option in the DEFAULT section of email2trac.conf file.

These instructions assume that DNS MX records are in place an email routing is already working.

Configuration changes:

  • To accept emails for the new domain:
    root@server:/etc/qmail# echo >> rcpthosts
  • To declare the new domain as a virtual domain, to ensure namespace separation of local usernames:
    root@server:/etc/qmail# echo >> virtualdomains
  • Add a rule to match all possible users of the new virtual domain, declaring they are all hosted in a directory where per-user .qmail files will be placed to determine further processing of messages, and ensure all further message processing will run as www-data user thus making the use of run_email2trac unnecessary:
    root@server:/etc/qmail# sed -i 's|^\.$|+trac-server-net-:www-data:33:33:/servers/trac/email2trac:-::\n.|' users/assign
  • Make changes take effect:
    root@server:/etc/qmail# qmail-newu
    root@server:/etc/qmail# /etc/init.d/qmail restart
  • Put per-user .qmail files in place, making messages go to the email2trac script:
    root@server:/servers/trac/email2trac# echo '|/usr/bin/preline /servers/trac/virtualenv/bin/python /servers/trac/email2trac/bin/email2trac --project=one' > .qmail-one
    root@server:/servers/trac/email2trac# echo '|/usr/bin/preline /servers/trac/virtualenv/bin/python /servers/trac/email2trac/bin/email2trac --project=two' > .qmail-two
    root@server:/servers/trac/email2trac# echo '|/usr/bin/preline /servers/trac/virtualenv/bin/python /servers/trac/email2trac/bin/email2trac --project=three' > .qmail-three

Test Setup

In the source distribution there is a file msg.txt. You can use this file to test the email2trac configuration:

  • Test with a command like :
    email2trac --project <name> < msg.txt 

If this command succeeds then email2trac is setup correctly, else you received an error on stdout or syslog, depends on your email2trac.conf setup.

The next step is to test the MTA setup. Use an email client to mail to the address you setup for email2trac, eg: subtrac@…