Nästa Föregående Innehållsförteckning

5. Smail v3.1

Smail 3.1 verkar vara en de-facto standard när det gäller e-post programvara för uucp-sajter och för vissa smtp-sajter. Det är lätt att konfigurera, det kompilerar från källkoden utan patchar och det är hyfsat säkert.

5.1 Att konfigurera smail

Installera binärfilerna för smail från din distribution (jag rekommenderar detta) eller hämta källkoden för smail och kompilera den. Om du kompilerar smail från källkod så måste du ha följande i din os/linux fil så att 'sed' ger dig shell-skript som fungerar ordentligt.

CASE_NO_NEWLINES=true 

När det väl är installerat så brukar konfigurationsfilerna läggas i /etc/smail/, så låt oss börja editera dem.

5.2 Filen config

# From
smart_path=polux
smart_transport=uux

# To
hostname=barberouge
domains=linux.lmm.com

visible_name=barberouge.linux.lmm.com
uucp_name=barberouge.linux.lmm.com

# max_message_size=512k
# auth_domains=foo.bar
# more_hostnames=barberouge.polux.freenix.fr

Okej, först, vem förser dig? Jag förses av "polux" via uucp (dvs uux transport). Du måste naturligtvis ändra denna fil så att den speglar din egen situation. Till exempel så skulle du kunna förses av "bargw.bar.foobar.com" via "smtp", i sådana fall behöver du ingen transports-fil och kan definiera "-transport_file" för att indikera att du inte behöver någon.

Du kan även använda 'postmaster_address = dittnamn', dölja nätverkstopologin i utgående adresser (om du är en gateway) genom att använda 'visible_name', specificera vilka alias som också kan användas för e-post som du tar emot, genom att använda 'more_hostnames'.

Se smail dokumentationen för mer detaljer eller dokumentationen i /usr/doc/smail/examples/ för att se om något passar din situation.

5.3 Filen directors

# aliasinclude - expand ":include:filename" addresses produced by alias files
# This entry and the next one are pretty much boiler-plate.  Reasons
# for making significant changes are few.  The sole purpose of these
# is to match and expand addresses of the form:
#       :include:pathname
# which may occur in alias files or mailing-list/forward files
# (produced by any director with a driver of forwardfile).
aliasinclude:
        driver = aliasinclude,          # use this special-case driver
        nobody;                         # associate nobody user with addresses
                                        #  when mild permission violations
                                        #  are encountered
        copysecure,                     # get permissions from alias director
        copyowners,                     # get owners from alias director



# forwardinclude - expand ":include:filename" addrs produced by forward files
forwardinclude:
        driver = forwardinclude,        # use this special-case driver
        nobody;
        copysecure,                     # get perms from forwarding director
        copyowners,                     # get owners from forwarding director


# aliases - search for alias expansions stored in a database
# This is the standard aliases file.  It is used for generic things,
# like mapping root, postmaster, MAILER-DAEMON and uucp to site
# admins, creating some small system alias expansions, and such.  In
# this site configuration, the aliases file is used mostly for
# machine-specific aliasing/forwarding information.  Global forwarding
# information should be put in the "forward" database.
aliases:
        driver=aliasfile,               # general-purpose aliasing director
        -nobody,                        # all addresses are associated
                                        # with nobody by default, so setting
                                        # this is not useful.
        sender_okay,                    # don't remove sender from expansions
        owner=owner-$user;              # problems go to an owner address
        file=/etc/aliases,
        modemask=002,                   # should not be globally writable
        optional,                       # ignore if file does not exist
        proto=lsearch,                  # unsorted ASCII file


# forward - search for expansions stored in a forwarding database
# This is the subdomain-wide user forwarding database.  Entries are
# maintained here for current or past users, to forward their mail to
# their preferred mail-reading machine.  The forward database is
# shipped around the TCP/IP network as changes are made, to keep the
# network consistent.
#forward:
#       driver = aliasfile,             # general-purpose aliasing director
#       -nobody,                        # all addresses are associated
#                                       # with nobody by default, so setting
#                                       # this is not useful.
#       owner = real-$user;             # problems go to an owner address
#
#       file = /etc/forward,
#       modemask = 002,
#       proto = dbm,                    # use dbm(3X) library for access


# dotforward - expand .forward files in user home directories
# For users that have an entry in the "forward" database, a ".forward"
# file is only used if it is on the "home" machine, as identified in
# the forward database.  If used, it is treated as a list of addresses
# to which mail should be delivered, rather than (or in addition to)
# the user identified in the local address.
dotforward:
        driver = forwardfile,           # general-purpose forwarding director
        owner = postmaster, nobody, sender_okay;

        file = ~/.forward,              # .forward file in home directories
        checkowner,                     # the user can own this file
        owners = root,                  # or root can own the file
        modemask = 002,                 # it should not be globally writable
        caution = daemon:root,          # don't run things as root or daemon
        # be extra carefull of remotely accessible home directories
        unsecure = "~uucp:/tmp:/usr/tmp:/var/tmp"


# forwardto - expand a "Forward to " in user mailbox files
# This emulates the V6/V7/System-V forwarding mechanism which uses a
# line of forward addresses stored at the beginning of user mailbox files
# prefixed with the string "Forward to "
forwardto:
        driver = forwardfile,
        owner = postmaster, nobody, sender_okay;

        file = /var/spool/mail/${lc:user},      # point at user mailbox files
        forwardto,                      # enable "Forward to " function
        checkowner,                     # the user can own this file
        owners = root,                  # or root can own the file
        modemask = 0002,                # under System V, group mail can write
        caution = daemon:root           # don't run things as root or daemon


# user - match users on the local host with delivery to their mailboxes
user:   driver = user;                  # driver to match usernames
        transport = local               # local transport goes to mailboxes


# real_user - match usernames when prefixed with the string "real-"
# This is useful for allowing an address which explicitly delivers to a
# user's mailbox file.  For example, errors in a .forward file expansion
# could be delivered here, or forwarding loops between multiple machines
# can be resolved by using a real-username address.  Also, users that
# wish to use mail as a means of transferring data to a machine that
# is not their "home" machine can mail to real-login-name@remote.host.
real_user:
        driver = user;
        transport = local,
        prefix = "real-"                # for example, match real-root


# lists - expand mailing lists stored in a list directory
# mailing lists can be created simply by creating a file in the
# /etc/smail/lists directory.
lists:  driver = forwardfile,
        caution,                        # flag all addresses with caution
        nobody,                         # and then associate the nobody user
        owner = owner-$user;            # system V sites may wish to use
                                        # o-$user, as owner-$user may be
                                        # too long for a 14-char filename.
        file = lists/${lc:user}         # lists is under $smail_lib_dir


# owners - expand mailing lists stored in a list owner directory
# mailing lists owner lists can be created simply by creating a file
# in the /etc/smail/lists/owner directory.  Mailing list owners
# are sent locally generated errors dealing with a mailing list of the
# same name.  To create an owner list for a mailing list, create a
# file with the name of the list in /etc/smail/lists/owner.  This
# will create a list address of owner-listname, as is used by the
# "lists" director above.
owners: driver = forwardfile,
        caution,                        # flag all addresses with caution
        nobody,                         # and then associate the nobody user
        owner = postmaster;             # system V sites may wish to use
                                        # o-$user, as owner-$user may be
                                        # too long for a 14-char filename.
        prefix = "owner-",
        file = lists/owner/${lc:user}   # lists is under $smail_lib_dir


# request - expand mailing lists stored in a list request directory
# mailing lists request lists can be created simply by creating a file
# in the /etc/smail/lists/request directory.  Request addresses
# are typically used as a standard address for queries about a mailing
# list.  For example, requests for additions or deletions to a list
# will generally be sent to "list-request", which should be set up to
# forward to the appropriate person or persons.
request: driver = forwardfile,
        caution,                        # flag all addresses with caution
        nobody,                         # and then associate the nobody user
        owner = postmaster;             # system V sites may wish to use
                                        # o-$user, as owner-$user may be
                                        # too long for a 14-char filename.
        suffix = "-request",
        file = lists/request/${lc:user} # lists is under $smail_lib_dir

Du bör inte behöva ändra något här, bara alternativ för e-post-listor om du tänker köra några med smail. Eller alternativ för vidareskickning (forwarding) om du till exempel vill inaktivera vidareskickning.

5.4 Filen fidopaths

.f105.n324.z2.fidonet.org       f105.n324.z2.fidonet.org!%s
.n324.z2.fidonet.org            f105.n324.z2.fidonet.org!%s
.z2.fidonet.org                 f105.n324.z2.fidonet.org!%s
.fidonet.org                    f105.n324.z2.fidonet.org!%s

Skapa endast denna filen om du använder ifmail och FIDO.

5.5 Filen routers

# forces - force certain paths
# This database exists as a means of hardcoding the paths to various
# machines or domains.  It is for use in creating temporary tweaks to
# the other routint databases.  To change the database, edit the file
# maps/force.path and type "make" in the maps/ subdirectory.
forces:
        driver = pathalias,             # router to search paths file
        method = /etc/smail/maps/table; # transports are in this file
        file = forcepaths,              # file containing force path info
        proto = lsearch,                # use the sorted path file
        optional,
        reopen                          # close when not being used


uucp_neighbors:
        driver=uuname,                  # use a program which returns neighbors
        transport=uux;
        cmd="/usr/bin/uuname -a",       # specifically, use the uuname program
#        domain=uucp                    # strip ending ".uucp"


# smart_host - a partically specified smarthost director
# If the config file attribute smart_path is defined as a path from the
# local host to a remote host, then hostnames not matched otherwise will
# be sent off to the stated remote host.  The config file attribute
# smart_transport can be used to specify a different transport.
# If the smart_path attribute is not defined, this router is ignored.
smart_host:
        driver = smarthost,             # special-case driver
        transport = uux                 # by default deliver over UUCP
#       path=phreak


# ifmail - to send mails to fidonet and vice versa
ifmail:
        driver=pathalias,
        transport=ifmail;
        file=fidopaths,
        proto=lsearch

Du skall endast inkludera ifmail-delen om du använder ifmail för FIDO post. Notera att du även kan byta transportläge från 'uux' (dvs UUCP) till, exempelvis, 'smtp' eller till och med 'hårdkoda vägarna till vissa maskiner eller domäner' i /etc/smail/maps/table.

Detta kan vara användbart om du vill att utgående e-post som är ämnat för ditt lokala nätverk skall skickas ut med en gång, eftersom det inte behöver routas till din uucp anslutning med Internet access.

5.6 Filen transports

# local - deliver mail to local users
# Tell smail to append directly to user mailbox files in the /var/spool/mail
# directory.
#local: driver = appendfile,            # append message to a file
#       -return_path,                   # include a Return-Path: field
#       local,                          # use local forms for delivery
#       from,                           # supply a From_ envelope line
#       unix_from_hack;                 # insert > before From in body
#
#       file = /var/spool/mail/${lc:user},      # use this location for Linux
#                                               # Note, mail spool must be 1777
#       file = ~/mailfile,              # use this location for better security
#       group = mail,                   # group to own file for System V
#       mode = 0660,                    # under System V, group mail can access
#       suffix = "\n",                  # append an extra newline
#       append_as_user,


# This allows each user to have a ~/.procmailrc file to control filtering
# of mail and saving mail from mail lists in separate mailboxes if they wish.
local:  +inet,
        -uucp,
        driver = pipe,                  # append message to a file
        return_path,                    # include a Return-Path: field
        local,                          # use local forms for delivery
        from,                           # supply a From_ envelope line
        unix_from_hack;                 # insert > before From in body

        cmd = "/usr/bin/procmail",      # use procmail for local delivery
        parent_env,                     # environment info from parent addr
        pipe_as_user,                   # use user-id associated with address
        umask = 0022,                   # umask for child process
#       -ignore_status,                 # exit status should be believed
#       -ignore_write_errors,           # retry on broken pipes


# pipe - deliver mail to shell commands
# This is used implicitly when smail encounters addresses which begin with
# a vertical bar character, such as "|/usr/lib/news/recnews talk.bizarre".
# The vertical bar is removed from the address before being given to the
# transport.
#pipe:  driver = pipe,                  # pipe message to another program
#       return_path, local, from, unix_from_hack;
#
#       cmd = "/bin/sh -c $user",       # send address to the Bourne Shell
#       parent_env,                     # environment info from parent addr
#       pipe_as_user,                   # use user-id associated with address
#       umask = 0022,                   # umask for child process
#       -log_output,                    # do not log stdout/stderr
#       ignore_status,                  # exit status may be bogus, ignore it
#       ignore_write_errors,            # ignore broken pipes


# file - deliver mail to files
# This is used implicitly when smail encounters addresses which begin with
# a slash or squiggle character, such as "/usr/info/list_messages" or
# perhaps "~/Mail/inbox".
#file:  driver = appendfile,
#       return_path, local, from, unix_from_hack;
#
#       file = $user,                   # file is taken from address
#       append_as_user,                 # use user-id associated with address
#       expand_user,                    # expand ~ and $ within address
#       check_path,
#       suffix = "\n",
#       mode = 0644


# uux - deliver to the rmail program on a remote UUCP site
#
# As many as five recipient addresses will be delivered to the remote
# host in one UUCP transaction.
uux:    driver = pipe,
        -uucp,
        inet,
#       uucp,                           # use UUCP-style addressing forms
        from,                           # supply a From_ envelope line
        max_addrs = 5,                  # at most 5 addresses per invocation
        max_chars = 200;                # at most 200 chars of addresses
# the -r flag prevents immediate delivery, parentheses around the
# $user variable prevent special interpretation by uux.
        cmd = "/usr/bin/uux - -r -g$grade $host!rmail $((${strip:user})$)",
#        cmd="/usr/bin/uux - $host!rmail $(($user)$)",
        ignore_write_errors,            # ignore broken pipes
        umask = 0022,
#       pipe_as_sender,


# uux_one_addr - deliver mail over UUCP to a remote host that can take
#                one address at a time.
# This is often necessary when delivering to a site running an unmodified
# version of 4.1BSD.
uux_one_addr:
        driver = pipe,
        uucp,                           # use UUCP-style addressing forms
        from;                           # supply a From_ envelope line
# the -r flag prevents immediate delivery
        cmd = "/usr/bin/uux - -r -g$grade $host!rmail (${strip:user})",
        umask = 0022,
        pipe_as_sender


queueonly:
        driver = pipe;                  # send the message to a pipe
        cmd = "/usr/lib/sendmail -Q -f $sender -bm $user",
                                        # use getmail for local delivery
        user=root,                      # execute getmail as "root"
        group=mail,                     # execute getmail as "mail"
        parent_env,                     # environment info from parent addr
        -pipe_as_user,                  # use user-id associated with address
        umask = 0007,                   # umask for child process
 
# to deliver the message.  The smtp transport is included only if BSD
# networking exists.
# The uucp attribute can be specified for transfers within the UUCP
# zone.  The inet attribute must be specified for transfers within the
# Internet.
# NOTE: This is hardly optimal, a backend should exist which can handle
#       multiple messages per connection.
# ALSO: It may be necessary to restrict max_addrs to 100, as this is the
#       lower limit SMTP requires an implementation to handle for one
#       message.
smtp:   driver=tcpsmtp,
        inet,                           # if UUCP_ZONE is not defined
#       uucp,                           # if UUCP_ZONE is defined
        -max_addrs, -max_chars;         # no limit on number of addresses

        short_timeout=5m,               # timeout for short operations
        long_timeout=2h,                # timeout for longer SMTP operations
        service=smtp,                   # connect to this service port
# For internet use: uncomment the below 4 lines
       use_bind,                       # resolve MX and multiple A records
       defnames,                       # use standard domain searching
       defer_no_connect,               # try again if the nameserver is down
       local_mx_okay,                  # fail an MX to the local host


ifmail:
        from,received,max_addrs=5,max_chars=200,
        driver=pipe;
        pipe_as_sender,
        cmd="/usr/local/bin/ifmail -x9 -r$host $((${strip:user})$)"

Du skall endast inkludera ifmail-delen om du använder ifmail för FIDO post. Förutom det skall du inte behöva ändra någonting i denna filen, vilken definierar transport-agenter (typ uux, smtp ...) som du kan använda som parametrar i andra konfigurationsfiler.

Notera att jag har kommenterat bort vissa delar, som 'pipes' eller 'file', för att öka säkerheten.

5.7 Katalogen maps/

Den innehåller filerna map och table:

Först filen map

#N      foo.bar foo2.bar2
#S      AT 486/RedHat Linux 1.2.13
#O      organization
#C      contact
#E      administration (email)
#T      phone
#P      address
#R
#U      hosts connected via uucp
#W      created/edited by
#
hname polux

hname linux.eu.org

hname = polux
hname = polux.linux.eu.org

Återigen så skall du ändra denna fil så att den speglar din situation (Jag förses av polux.linux.eu.org).

Nu filen table

 
*       uux

Du kan definiera olika transportsätt till olika vägar, till exempel 'smtp' för maskinerna i ditt lokala nätverk, 'uux' (dvs uucp) för resten av världen eller vice-versa (Jag använder uucp för all utgående e-post, därför har jag '*').

5.8 Andra bra exempel

De förra filerna är de jag för närvarande använder för min sajt, du bör inte stöta på några problem med att använda dem som grund för dina egna filer.

Följande filer har jag med för att visa andra bra exempel på hur man kan konfigurera smail på ett annat sätt.

#ident "@(#) transports,v 1.2 1990/10/24 05:20:46 tron Exp"

# See smail(5) for a complete description of the contents of this file.

# local - deliver mail to local users
#
# Tell smail to append directly to user mailbox files in the /usr/mail
# directory.
local:  driver = appendfile,            # append message to a file
        return_path,                    # include a Return-Path: field
        local,                          # use local forms for delivery
        from,                           # supply a From_ envelope line
        unix_from_hack;                 # insert > before From in body

        file = /usr/mail/${lc:user},    # use this location for System V
        group = mail,                   # group to own file for System V
        mode = 0660,                    # under System V, group mail can access
        suffix = "\n",                  # append an extra newline
        append_as_user,

# pipe - deliver mail to shell commands
#
# This is used implicitly when smail encounters addresses which begin with
# a vertical bar character, such as "|/usr/lib/news/recnews talk.bizarre".
# The vertical bar is removed from the address before being given to the
# transport.
pipe:   driver = pipe,                  # pipe message to another program
        return_path, local, from, unix_from_hack;

        cmd = "/bin/sh -c $user",       # send address to the Bourne Shell
        parent_env,                     # environment info from parent addr
        pipe_as_user,                   # use user-id associated with address
        umask = 0022,                   # umask for child process
        -log_output,                    # do not log stdout/stderr
        ignore_status,                  # exit status may be bogus, ignore it
        ignore_write_errors,            # ignore broken pipes

# file - deliver mail to files
#
# This is used implicitly when smail encounters addresses which begin with a
# slash or squiggle character, such as "/usr/info/list_messages" or perhaps
# "~/Mail/inbox".
file:   driver = appendfile,
        return_path, local, from, unix_from_hack;

        file = $user,                   # file is taken from address
        append_as_user,                 # use user-id associated with address
        expand_user,                    # expand ~ and $ within address
        suffix = "\n",
        mode = 0644

# uux - deliver to the rmail program on a remote UUCP site
#
# As many as five recipient addresses will be delivered to the remote host in
# one UUCP transaction.
uux:    driver = pipe,
        uucp,                           # use UUCP-style addressing forms
        from,                           # supply a From_ envelope line
        max_addrs = 5,                  # at most 5 addresses per invocation
        max_chars = 200;                # at most 200 chars of addresses

        # the -r flag prevents immediate delivery, parentheses around the
        # $user variable prevent special interpretation by uux.
        cmd = "/usr/bin/uux - -r -g$grade $host!rmail $((${strip:user})$)",
        umask = 0022,
        pipe_as_sender

# uux_one_addr - deliver mail over UUCP to a remote host that can take one
# address at a time.
#
# This is often necessary when delivering to a site running an unmodified
# version of 4.1BSD.
uux_one_addr:
        driver = pipe,
        uucp,                           # use UUCP-style addressing forms
        from;                           # supply a From_ envelope line

        # the -r flag prevents immediate delivery
        cmd = "/usr/bin/uux - -r -g$grade $host!rmail (${strip:user})",
        umask = 0022, pipe_as_sender

# demand - deliver to a remote rmail program, polling on demand
demand: driver = pipe,
        uucp, from, max_addrs = 5, max_chars = 200;

        # with no -r flag, try to contact remote site immediately
        cmd = "/usr/bin/uux - -g$grade $host!rmail $(($user)$)",
        umask = 0022, pipe_as_sender

# uusmtp - deliver to the rsmtp program on a remote UUCP site
#
# Deliver using a simple Batched SMTP protocol to the remote machine.
# This allows much more arbitrary addresses to be used.  It also
# removes the limit on recipient addresses per invocation of uux.
uusmtp: driver = pipe,
        bsmtp,                          # send batched SMTP commands
        -max_addrs,                     # there is no limit on the number or
        -max_chars;                     #   total size of recipient addresses.

        # supply -r to prevent immedate delivery, the recipient addresses
        # are stored in the data sent to the standard input of rsmtp.
        cmd = "/usr/bin/uux - -r -g$grade $host!rsmtp",
        umask = 0022, pipe_as_sender

# demand_uusmtp - deliver to a remote rsmtp program, polling on demand
demand_uusmtp:
        driver = pipe,
        bsmtp, -max_addrs, -max_chars;

        # with no -r flag, try to contact remote site immediately
        cmd = "/usr/bin/uux - -g$grade $host!rsmtp",
        umask = 0022, pipe_as_sender

# smtp - deliver using SMTP over TCP/IP
#
# Connect to a remote host using TCP/IP and initiate an SMTP conversation to
# deliver the message.  The smtp transport is included only if BSD networking
# exists.

# NOTE: It may be necessary to restrict max_addrs to 100, as this is the
#       lower limit SMTP requires an implementation to handle for one
#       message.
smtp:   driver = smtp,
        -max_addrs,
        -max_chars

#ident "@(#) table,v 1.2 1990/10/24 05:20:31 tron Exp"

# This file names the transports that are to be used in delivering
# to specific hosts from bargw.

#host           transport
#--------       ---------
curdsgw         demand_uusmtp   # deliver using batched SMTP
oldbsd          uux_one_addr    # 4.1BSD sites cannot take more than one addr
sun             demand          # call sun when their is mail to send
*               uux             # for all others, poll at intervals

5.9 Starta om inetd

För att köra smail som en smtp daemon, lägg till en av följande rader i /etc/inetd.conf:

         smtp stream tcp nowait  root  /usr/bin/smtpd smtpd

eller:

         smtp stream tcp nowait  root  /usr/sbin/tcpd  /usr/sbin/in.smtpd

Utgående e-post skickas automatiskt, om man använder elm.

5.10 Smail med smtp

Vanligtvis så använder internetleverantörer smtp, därför skall du inte ha några problem med att skicka din e-post. Om din Internet-koppling är nere när du skickar e-post, så sparas den i /var/spool/smail/input/. När kopplingen kommer upp så körs runq som gör att e-posten skickas iväg. Men problemet är att ta emot e-post eftersom din leverantör har många kunder att se efter, inte bara dig.

Vanligtvis kan du hämta din e-post via POP-protokollet, se POP-avsnittet nedan.


Nästa Föregående Innehållsförteckning