### Integration with Postfix ¶

This section is taken from Postfix and UUCP manual and just replaces UUCP-related calls with NNCP ones.

Setting up a Postfix Internet to NNCP gateway

Here is how to set up a machine that sits on the Internet and that forwards mail to a LAN that is connected via NNCP.

- You need an `nncp-exec` program that extracts the sender address from mail that arrives via NNCP, and that feeds the mail into the Postfix `sendmail` command.
- Define a `pipe(8)` based mail delivery transport for delivery via NNCP:

      /usr/local/etc/postfix/master.cf:
      nncp      unix  -       n       n       -       -       pipe
        flags=Rqhu user=nncp argv=nncp-exec -quiet $nexthop sendmail $recipient

  This runs the `nncp-exec` command to place outgoing mail into the NNCP queue after replacing $nexthop by the receiving NNCP node and after replacing $recipient by the recipients. The `pipe(8)` delivery agent executes the `nncp-exec` command without assistance from the shell, so there are no problems with shell meta characters in command-line parameters.

  Pay attention to `flags`, containing `R`, telling Postfix to include `Return-Path:` header. Otherwise that envelope sender information may be lost. Possibly you will also need somehow to preserve that header on the receiving side, because `sendmail` command will replace it. For example you can rename it before feeding to `sendmail` with `reformail -R Return-Path: X-Original-Return-Path: | sendmail`, or extract with:

      #!/bin/sh -e

      tmp=`mktemp`
      trap "rm -f $tmp" HUP PIPE INT QUIT TERM EXIT
      cat >$tmp
      sendmail -f "`reformail -x Return-Path: <$tmp`" $@ <$tmp

  Also pay attention that `maildrop` does not like `From_` mbox-style header, so you possibly want:

      mailbox_command = reformail -f0 | maildrop -d ${USER}

- Specify that mail for example.com, should be delivered via NNCP, to a host named nncp-host:

      /usr/local/etc/postfix/transport:
          example.com     nncp:nncp-host
          .example.com    nncp:nncp-host

  See the `transport(5)` manual page for more details.

- Execute the command `postmap /etc/postfix/transport` whenever you change the `transport` file.
- Enable `transport` table lookups:

      /usr/local/etc/postfix/main.cf:
          transport_maps = hash:$config_directory/transport

- Add example.com to the list of domains that your site is willing to relay mail for.

      /usr/local/etc/postfix/main.cf:
          relay_domains = example.com ...other relay domains...

  See the `relay_domains` configuration parameter description for details.

- Execute the command `postfix reload` to make the changes effective.

Setting up a Postfix LAN to NNCP gateway

Here is how to relay mail from a LAN via NNCP to the Internet.

- You need an `nncp-exec` program that extracts the sender address from mail that arrives via NNCP, and that feeds the mail into the Postfix `sendmail` command.
- Specify that all remote mail must be sent via the `nncp` mail transport to your NNCP gateway host, say, nncp-gateway:

      /usr/local/etc/postfix/main.cf:
          relayhost = nncp-gateway
          default_transport = nncp

  Postfix 2.0 and later also allows the following more succinct form:

      /usr/local/etc/postfix/main.cf:
          default_transport = nncp:nncp-gateway

- Define a `pipe(8)` based message delivery transport for mail delivery via NNCP:

      /usr/local/etc/postfix/master.cf:
      nncp      unix  -       n       n       -       -       pipe
        flags=Fqhu user=nncp argv=nncp-exec -quiet $nexthop sendmail $recipient

  This runs the `nncp-exec` command to place outgoing mail into the NNCP queue. It substitutes the hostname (nncp-gateway, or whatever you specified) and the recipients before execution of the command. The `nncp-exec` command is executed without assistance from the shell, so there are no problems with shell meta characters.

- Execute the command `postfix reload` to make the changes effective.