letterbox

A simple SMTP to Maildir delivery agent
git clone https://www.brianlane.com/git/letterbox
Log | Files | Refs | README | LICENSE

README.md (2223B)


      1 # letterbox - SMTP to Maildir delivery agent
      2 
      3 This is a simple Go program that accepts SMTP connections and delivers mail to
      4 a per-user maildir directory. I use it to gather reports from various services
      5 on my LAN without needing to setup postfix or some other more complex MTA.
      6 
      7     Usage of letterbox:
      8       -config string
      9             Path to configutation file (default "letterbox.toml")
     10       -host string
     11             Host IP or name to bind to
     12       -maildirs string
     13             Path to the top level of the user Maildirs (default "/var/spool/maildirs")
     14       -port int
     15             Port to bind to (default 25)
     16 
     17 The configuration file is written using
     18 [TOML](https://github.com/toml-lang/toml). You must specify at least one
     19 host/network and one email otherwise delivery will fail. For example:
     20 
     21     hosts = ["192.168.1.0/24", "127.0.0.1", "logger.mydomain.com"]
     22     emails = ["root@mydomain.com", "user@another.com"]
     23 
     24 If the connection is not from an allowed host the connection will be refused.
     25 Destination emails must be listed in the `emails` list. The user portion of the
     26 email will be used to create a new maildir under the `-maildirs` path. For
     27 example, sending an email to user@another.com will create a new maildir at
     28 `/var/spool/maildirs/user`.
     29 
     30 You will likely want to create your maildirs someplace else. On my system the
     31 `/var/spool/maildirs` directory is owned by the user that is running `letterbox`.
     32 
     33 
     34 ## Redirect port 25
     35 
     36 *Never* run this as root.
     37 
     38 Use a higher port, like 2525, and configure your system's firewall to redirect port 25 to it.
     39 For example, using nft, you can do this by adding:
     40 
     41     # redirect 25 to 2525
     42     table nat {
     43       chain prerouting {
     44         type nat hook prerouting priority 0;
     45         tcp dport 25 dnat :2525
     46       }
     47       chain postrouting {
     48         type nat hook postrouting priority 0;
     49       }
     50     }
     51 
     52 Or with iptables:
     53 
     54     *nat
     55      -A PREROUTING -p tcp -d SERVERIP --dport 25 -j REDIRECT --to-ports 2525
     56      COMMIT
     57 
     58 Replace the SERVERIP with the IP of the server letterbox is running on.
     59 
     60 
     61 # WARNING
     62 
     63 This code is not meant to be run on the open network. Make sure it is protected behind a firewall,
     64 and is running as an un-privileged user. *Never* run it as root.