Kom stands for "Keep old mails". It imports emails in a MySQL database and provides a frontend in gtk2 to search and browse the archived emails. Some options can be used to incrementally import mails (do to it each month for example). It can also export mails stored in the database, in mbox format or one-message-per-file format, and generate some statistics.
I use to keep a lot of e-mails, and it's becoming a pain:
Of course I could add some more filters, reorganize them by date, ..., but it does not makes them easier to find, for example when I don't know the date of a message I'm looking for. Archiving the messages in a database allows to search quickly according to the value of some fields ("To:", "From:", ...) or the contents of the body.
Another usage I think about is doing statistics on my e-mails. Just for fun.
To compile Kom, you need the following tools and libs being installed:
Then, retrieve the source distribution (see the releases) and follow the instructions in the INSTALL file.
You need to have all rights on a MySQL database on a MySQL server. By default, this database is "kom" on "localhost" and you connect to this database using your login and no password. The port used is the default MySQL port by default.
To set up this database, if you have admin privileges on the MySQL server, connect to the server and do:
create database kom; grant all privileges on kom.* to yourlogin@localhost;
Refer to the MySQL reference manual for more information. The above command does not require a password to connect to your database "kom", so anybody on the local machine can connect as you using the -u option and see your archived messages. To prevent this, you should add identified by 'password' to the grant ... statement to set up a password.
You can check that you can connect to the database by using the mysql command line tool.
Once it is ok, you must initialize the tables and indices with the kom command:
You can indicate other values than the default ones for the database name, login, host, password and port with the options -d, -u, -h, -p and -P respectively. For example, if you want to use the login geebuz and password mypw to connect to your database foobar which is on machine mach, use the following command:
kom init -u geebuz -p mypw -d foobar -h mach
The same options are needed by all kom commands, since they all need to connect to the database.
Importing messages is done with the import subcommand. This command has the following form:
kom import [connection options] [import options] <files and directories>
The connection options are the same as for the init command (see above). The files and directories indicate what messages to import. By now, there is only two formats supported for messages:
If a directory is indicated as argument to import, then all files in the directory are imported, and all subdirectories if the -r import option is given. The file utility is used to guess if a file is a RFC 822 one or a mbox. In the doubt, the tool assumes that the file in mbox format.
At the end of the import, the file kom_import.log contains the error and warning messages issued and the number of errors, warnings and correctly imported files.
When a message is imported in the database, it is associated to a folder. The database contains a tree of folders. Each message in the database is associated to a folder. Folders are not directories, though directories where a message file is stored are used to know which folder the imported message must be associated to. Let's see an example with the following command:
kom import -r dir0/file1 dir0/file2 dir1 dir2/dir3
This command will import:
Folders in the database are automatically created when missing.
Some options can change the behaviour of the import:
Be aware that windows files will not be correctly handled because kom does not handle the Windows end of line characters ('\r\n'). To import Windows files, you need to convert them to unix format (using only '\n' as end of line character). You can use the dos2unix utility to do so.
The tool can also export messages stored in the database. It can export all the messages or only the ones matching a given filter. For example:
will export all messages into the current directory, creating directories to match the folders in the database. Each messages is exported in a separate file in RFC 822 format. It is possible to export in mbox files (one per directory) and only some messages with a command like:
kom export --mbox --filter "date: < 2004/01/01"
The --no-subdirs flag can be used to ask the tool to export all messages in the same directory, ignoring the folder each message belongs to. At last, the -o option can be used to specify a different export directory.
A small language allows to define filters on messages, that is conditions on various fields to retrieve messages. Here is a description of this language in BNF-style:
FILTER ::= | ATOM | FILTER and FILTER | FILTER or FILTER | not FILTER | ( FILTER ) ATOM ::= | to: STRING | from: STRING | cc: STRING | body: STRING | subject: STRING | folder: STRING | OTHER_FIELD STRING | date: < DATE | date: > DATE | size: < INT | size: > INT | DATE > date: > DATE | DATE < date: < DATE OTHER_FIELD ::= [a-z|A-Z|0-9|'_'|'-']+':' STRING ::= | quoted_string | [^'\n' '"' '(' ')' ' ' '\009' '\012' ':' '/' '<' '>']+ DATE ::= year DATE_SEP month DATE_SEP day | year DATE_SEP month DATE_SEP day DATE_SEP hour DATE_SEP minute DATE_SEP ::= ['/' ':'] INT ::= (0..9)+
An "other field" (or custom field) is a message header field. A custom field in a filter will only have effect if you have declared that you want to use this field in filters. You can manage these custom fields with the add-fields and remove-fields operations. For example:
kom add-fields x-mailer: user-agent:
will declare the two header fields x-mailer: and user-agent: as custom fields. Do not forget the ending ':'. From a concrete point of view, a column is added to the messages table for each custom field, thus allowing the filtering on it. For example, you can retrieve who used sylpheed in your message with a filter like x-mailer: sylpheed.
kom remove-fields x-mailer: user-agent:
will remove the custom fields.
Adding and removing custom fields can also be done from the graphical interface.
The kom.gui command launches the gtk2-based graphical interface to browse and display folders and messages.
The "Filter" entry at the top of the window can be used to enter the filter used to retrieve messages.
Hitting the Enter key in the filter box displays the list of messages corresponding to the filter. In this list, selecting a message displays it below the message list. The border of the filter box becomes red when hitting Enter on a syntactically incorrect filter.
You can "bookmark" the current filter by clicking on the floppy icon on the right of the filter entry. You will be asked for a name for that filter. Then, the filter is stored in the database and you can select it in the bottom-left list to appy it. You can use such "bookmarks" for your frequently used filters.
The project is hosted on Gna!.
Kom is distributed under the GPL license.
|1.05 (2009-06-04)||The size of each message is stored in a field, so that it is displayed in the message list and searches can be performed on the size using size: in filters. A popup menu bound to button 3 in the message list allows to delete a message from the database.|
|1.03 (2008-12-04)||Some bug fixes, no need for Camomile any more, new activity.x tool, new kom_tdl tool to export todo lists (with Cameleon2's TDL library) from mails.|
|1.02 (2006-07-31)||Use "in-reply-to:" field when no "to:" field is found.|
Bug fix: a file descriptor was not closed, given a "too many open files" error.
Optimize the display of filtered messages. If their number is greater than full_retrieve_max, the body is only retrieved when the full message must be displayed. full_retrieve_max can be specified in the ~/.komrc file.
|1.0 (2006-07-07)||Initial release.|