michael orlitzky

list-remote-forwards

Get It

Release
list-remote-forwards-0.0.4.tar.gz
Browse source
gitweb
Clone it
git clone https://gitweb.michael.orlitzky.com/list-remote-forwards.git

What is it?

A utility to keep tabs on the remote forwards in your MTA.

Assuming that your user/domain information is stored in a database, a list of local domains is supplied to the program (more or less) through the --domain-query option. Any addresses in the list that forward to an address not in the list are considered remote forwards. Remote forwards can cause problems for a number of reasons, the most common of which are,

Whether or not these affect you depends on your circumstances, but in any case it is useful to know who is forwarding mail off-site.

input & output

list-remote-forwards doesn't take any input. It gets its “input” from your database. It outputs the list of addresses that are forwarded to remote domains. You’ll probably want to run it as a cron job.

Options

--database

The name of the database (or file, if SQLite) to which we should connect. Default: The name of the current user (Postgres only).

--domain-query

SQL query used to produce a list of local domains. This should return the set of all domains (i.e one column) that are local to the server. See the default value for an example.

Default: SELECT domain FROM domain WHERE domain <> 'ALL' ORDER BY domain;

--exclude-mx, -e

The name of a mail exchanger, the forwards of whose domains we should ignore. For example, if one mail exchanger, mx1.example.com, has strict spam filtering, it may be acceptable to have remote forwarding for domains that have mx1.example.com as their sole mail exchanger (MX record). In that case, you might want to exclude those domains from the report by naming mx1.example.com here. A forward will be excluded from the report only if all of its MX records are contained in the given exclude list. This option can be repeated to add mail exchangers to the exclude list.

Default: [] (empty).

--forward-query, -f

SQL query used to produce a list of all forwards on the mail system. This query should return the set of all (address, goto) pairs, where goto; is the destination address; i.e. to where the address forwards. The goto field may contain more than one email address, separated by commas.

Default: SELECT address,goto FROM alias ORDER BY address;

host, -h

Hostname where the database is located (Postgres-only).

Default: None, a UNIX domain socket connection is attempted (Postgres only).

--password

Password used to connect to the database (Postgres-only).

Default: None (assumes passwordless authentication).

--port

Port number used to connect to the database (Postgres-only).

Default: None, a UNIX domain socket connection is attempted (Postgres only).

--username, -u

Username used to connect to the database (Postgres-only).

Default: The current user.

Configuration file

Any of the options above can be placed in a configuration file rather than passed on the command line. An example config file doc/list-remote-forwardsrc.example is included with the source. You can edit it and rename it to either $sysconfdir/list-remote-forwardsrc or ~/.list-remote-forwardsrc. The variable $sysconfdir is determined at build time and is typically /etc on UNIX systems.

Examples

user $ list-remote-forwards --database=test/fixtures/postfixadmin.sqlite3

user1@example.com -> user1@example.net

user2@example.com -> user1@example.org

user2@example.com -> user2@example.org

user2@example.com -> user3@example.org

user7@example.com -> user8@example.net

Requirements

All of the software dependencies are listed in the list-remote-forwards.cabal file. Just use cabal to build it.

Installation

Cabal handles the build, so do whatever you normally do to install cabal packages. If you just want to install it for your user,

user $ runghc Setup.hs configure --user

user $ runghc Setup.hs build

user $ runghc Setup.hs install

should do it.

How to report bugs

Email them to me at michael@orlitzky.com.