This PHP based mail2trac script reads from a POP3 or IMAP mailbox and imports messages as Tickets with Attachments. It is designed to be run via cron on some periodic basis.


The mail2trac system is designed to be run via cron or some other command scheduler to attach to a mailbox, pull message, create tickets, delete the messages and close the connection. It will only process one mailbox at a time, then exit. To collect from multiple mailboxes simply run multiple commands. Or configure SMTP routing to get all the necessary mesages in a single mailbox.


While small, mail2trac delivers some nifty features.

We also have this list of non-features, things we don't do


The mail2trac.php script is written for PHP 5.3 or newer and requires the IMAP extensions. The Trac system must be at least 0.11 and have the XML-RPC plugin.

Now install this script with the following, adjust to your environment

root@host # mkdir -p /opt/edoceo/bin; cd /opt/edoceo/bin
root@host # wget
root@host # chmod 0755 mail2trac.php

Create a configuration file

; Fetch POP3 Mail
host = "{}INBOX"

; Fetch IMAP Mail over SSL
;host = "{}INBOX"

user = "help@domain.tld"
pass = "secret"
trac = "http://user:pass@host/trac/login/rpc"

Tickets will be automatically created in Trac with defaults. We suggest creating a default milestone of Active Queue for triage. We are also available for assistance on this or other Trac related issues, just contact us.

See Also