===== Magimail configuration =====

Magimail is a fork of Crashmail-II and is configured using a `magimail.prefs`
file in the working directory that you call magimail from. I usually put my
prefs file in the `MagickaBBS/ftn/` directory.

==== Example magimail.prefs file ====

Here is a sample template you can use to get started configuring magimail,
along with explainations for each command. Please note there are many more
commands you can use for more advanced setup. The full documentation is in
`MagickaBBS/utils/magimail/doc/example.prefs`.

    SYSOP "Your Name"
    BBSNAME "Some BBS"

    LOGFILE "/path/to/MagickaBBS/logs/magimail.log"
    LOGLEVEL 3

    DUPEFILE "/path/to/MagickaBBS/ftn/dupes.log" 200
    DUPEMODE BAD

    LOOPMODE LOG+BAD

    MAXPKTSIZE 50
    MAXBUNDLESIZE 100

    DEFAULTZONE 637

    INBOUND "/path/to/MagickaBBS/ftn/in_sec"
    OUTBOUND "/path/to/MagickaBBS/ftn/out"
    TEMPDIR "/path/to/MagickaBBS/ftn/cm_temp"
    CREATEPKTDIR "/path/to/MagickaBBS/ftn/cm_temp"
    PACKETDIR "/path/to/MagickaBBS/ftn/cm_packets"
    STATSFILE "/path/to/MagickaBBS/ftn/magimail.stats"
    ANSWERRECEIPT
    ANSWERAUDIT
    CHECKSEENBY
    IMPORTAREAFIX
    IMPORTSEENBY
    WEEKDAYNAMING
    ADDTID
    ALLOWRESCAN
    INCLUDEFORWARD
    ALLOWKILLSENT

    GROUPNAME A "happynet"

    PACKER "ZIP" "zip -j %a %f" "unzip -j %a" "PK"

    AKA 637:1/999
    DOMAIN happynet

    NODE 637:1/100 "ZIP" "" AUTOADD PACKNETMAIL
    DEFAULTGROUP A

    ROUTE "637:*/*.*" "637:1/100.0" 637:1/999

    JAM_HIGHWATER
    JAM_LINK
    JAM_QUICKLINK
    JAM_MAXOPEN 5

    NETMAIL "NETMAIL" 637:1/999 JAM "/path/to/MagickaBBS/msgs/hpy_netmail"

    AREA "BAD" 637:1/999 JAM "/path/to/MagickaBBS/msgs/bad"

    AREA "DEFAULT_A" 637:1/999 JAM "/path/to/MagickaBBS/msgs/%l"

    AREA "HPY_GEN" 637:1/999.0 JAM "/path/to/MagickaBBS/msgs/hpy_gen"
    EXPORT %637:1/100.0
    GROUP A

==== General Configuration ====

**SYSOP**

This is your name

**BBSNAME**

This is the name of your BBS

**LOGFILE**

The file to use as a log.

**LOGLEVEL**

The amount of verbosity to use, 3 is normal, 1 is minimal and 6 is debug mode.

**DUPEFILE**

The name of the DUPE file, and the number of messages to store.

**DUPEMODE**

This can be **BAD** for moving dupes to a BAD area (defined later) **KILL** to
kill them or **IGNORE** to pass them.

**LOOPMODE**

When magimail encounters a netmail stuck in a loop it can, **LOG** it,
**LOG+BAD** log it and send it to the **BAD** area, or IGNORE it.

**MAXPKTSIZE**

The maximum size of a packet before magimail creates a new packet. In KB.

**MAXBUNDLESIZE**

The maximum size of a bundle of packets, In KB.

**DEFAULTZONE**

This is the default zone, if magimail can't figure out the zone any other way,
it uses this.

**INBOUND**

The directory magimail looks for packets and bundles to toss.

**OUTBOUND**

The directory magimail writes flow files that tells binkd what files to send.

**TEMPDIR**

The directory magimail unpacks incoming bundles.

**CREATEPKTDIR**

Packets are created in this directory before they are moved to the 
**PACKETDIR**

**PACKETDIR**

This directory is where magimail stores bundles.

**STATSFILE**

This file stores stats about the usage of magimail. You can view the stats
with the magistats utility.

**FORCEINTL**

Magimail should add an INTL line to netmails even if the sender and recipient
are in the same zone.

**ANSWERRECIPT** 

Magimail will honour recipt requests.

**ANSWERAUDIT** 

Magimail will honour audit requests.

**CHECKSEENBY** 

Magimail should never send a message to a node in the SEEN-BY lines.

**IMPORTAREAFIX**

Import magimail's areafix into the netmail area.

**IMPORTSEENBY**

Import seen-by lines.

**WEEKDAYNAMING**

Name bundles according to the weekday they were created.

**ADDTID**

Add a TID line to all messages exported by magimail.

**ALLOWRESCAN**

Allow nodes to rescan areas with Areafix.

**INCLUDEFORWARD** 

Include all forward-requestable areas in the area listsgenerated by the
Areafix.

**ALLOWKILLSENT**

Magimail will delete netmails that have the KILLSENT flag after they have
been exported.

==== Group Names ====

These are description for groups for use by areafix, there can be multiple
entries.

**GROUPNAME** 

This is the letter for the group and a description in quotation marks.

==== Packers ====

Here you configure the external packers that Magimail uses. %a stands for
archive name and %f stands for file name. The recog string is used when 
Magimail detects the packer used to pack a bundle. If the beginning of the
bundle matches the recog string, Magimail uses that packer. ? can be used
as a wildcard and you can use $xx to specify a hexadecimal number.

**PACKER**

[name] [pack command] [unpack command] [recog]

==== AKA ====

You can have multiple AKAs, these are your addresses given to you by networks.

**AKA** 

A network address

**DOMAIN**

The domain for the network.

==== Nodes ====

You should configure a node section for every node you export packets to, in a
typical setup, there will only be one for your hub.

**NODE**

[address] [packer] [packet password] [flags] Flags in the exampleconfig are
**AUTOADD** to automatically add areas you receive mail for, and
**PACKNETMAIL** to pack netmail along with the echomail.

**DEFAULTGROUP**

The default group this node has access to.

==== Routing ====

Netmails who's destination matches a pattern are routed to destination pattern
using the specified AKA

**ROUTE** 

[pattern] [destination pattern] [aka]

==== JAM Configuration Options ====

**JAM_HIGHWATER**

Use a highwater mark to speed up scanning.

**JAM_LINK**

Do reply-linking based on MSGID and REPLY after import.

**JAM_QUICKLINK**

Just compare the CRC of MSGID/REPLY when linking and don't read the strings
from the messagebase. This makes linking quicker, but messages that don't
match may be linked by mistake.

**JAM_MAXOPEN**

The maximum number of JAM areas opened at one time.

==== Areas ====

**AREA/NETMAIL/LOCALAREA**

[tagname] [aka] [messagebase] [path]

message base can be JAM or SQ3, JAM is recommended.

**EXPORT**

Nodes to export to.

**GROUP**

The letter of the group this area is in.

==== Example magitoss.sh ====

    #!/bin/sh
    cd /path/to/MagickaBBS/ftn
    ../utils/magimail/bin/magimail toss

==== Example magiscan.sh ====

    #!/bin/sh
    cd /path/to/MagickaBBS/ftn
    ../utils/magimail/bin/magimail scan

==== Watching for New Mail ====

When new mail is created on your bbs, a semaphore file is touched. So, you
need to run a script that watches for changed semaphores and runs
`magiscan.sh`.

On Linux and FreeBSD this can be accomplished with inotifytools. On other
platforms, an alternative called FSWatch 
(https://github.com/emcrisostomo/fswatch) is available.

==== Example watchmail.sh (inotifytools) ====

    #!/bin/sh
    
    cd /path/to/MagickaBBS

    touch mail.out

    while inotifywait -e close_write mail.out; do ./ftn/magiscan.sh;done

==== Example watchmail.sh (fswatch) ====

    #!/bin/sh

    touch /path/to/MagickaBBS/mail.out
    
    /usr/local/bin/fswatch -o /path/to/MagickaBBS/mail.out | xargs -n1 -I{} /path/to/MagickaBBS/ftn/magiscan.sh
.