##
##  lmtp2nntp.conf -- Mail to News Gateway Configuration
##

#   --- DAEMON ---
user               @l_musr@
childsmax          3
pidfile            "@l_prefix@/var/lmtp2nntp/lmtp2nntp.pid"

#   --- LMTP SERVER ---

#   server communication on TCP socket (address:port)
#acl               127.0.0.1/32
#bind              127.0.0.1:24

#   server communication on Unix domain socket (path:permissions)
bind               "@l_prefix@/var/lmtp2nntp/lmtp2nntp.socket:660"

#   server communication on stdin/stdout (remove DAEMON section above)
#bind              -

#   server communication limits
timeoutlmtp        0
timeoutlmtpaccept  0
timeoutlmtpread    10
timeoutlmtpwrite   10
size               8388608

#   ---- NNTP CLIENT ----

#   client communication via TCP socket
#client            127.0.0.1
destination        127.0.0.1:nntp

#   client communication limits
timeoutnntp        30
timeoutnntpconnect 60
timeoutnntpread    60
timeoutnntpwrite   60
operationmode      post

#   ---- GATEWAY OPERATION ----

#   processing mode
groupmode          envelope
mailfrom           ".*"
nodename           "gateway"
restrictheader     "X-Gateway:.*lmtp2nntp"
newsgroup          "local.test"

#   remove headers (using empty value)
headerrule         '500:^(-EF|Path|Received|To|Cc|Bcc|):$1:'

#   merge values from duplicate headers and separte them with "comma space"
headerrule         '510:^(Reply-To):$1:[${msg.header.${1}[#]}${msg.header.${1}[#+1]:+, }]'

#   replace empty Subject with text "None"
headerrule         '520::Subject:${msg.header.Subject:-None}'

#   create Message-ID if omitted or illegal (no or more than one '@')
headerrule         '530::Message-ID:${msg.header.Message-ID:-@@:s/^.*@.*@.*$//:%createmessageid}'

#   append a header to inhibit bang path addressing for mail replies
headerrule         '540::Path:lmtp2nntp!not-for-mail'

#   append a header to avoid message loops with news2mail gateways - see restrictheader
headerrule         '610::X-Gateway:lmtp2nntp'

#   append a header to approve posting to a moderated newsgroup
headerrule         '620::Approved:gateway@example.com'

#   ---- LOGGING ----

#   normal operation
l2spec             'info:  prefix(prefix="%b %d %H:%M:%S <%L> lmtp2nntp[%P]: ", timezone=local) \
                        -> buffer(size=65536) \
                        -> file(path="@l_prefix@/var/lmtp2nntp/lmtp2nntp.log", append=1, perm=0640)'

#   normal and debug operation
#l2spec            'noop -> { \
                    info:  prefix(prefix="%b %d %H:%M:%S <%L> lmtp2nntp[%P]: ", timezone=local) \
                        -> buffer(size=65536) \
                        -> file(path="@l_prefix@/var/lmtp2nntp/lmtp2nntp.log", append=1, perm=0640); \
                    debug: prefix(prefix="%b %d %H:%M:%S <%L> lmtp2nntp[%P]: ", timezone=local) \
                        -> file(path="@l_prefix@/var/lmtp2nntp/lmtp2nntp.debug", append=0, perm=0640) }'

#   raw debug operation only
#l2spec            'debug: fd(fd=2)'

