broken since release 26

The Pliant SMTP server has been design with deap layering in mind. Rather than providing a straight forward to use server, the Pliant SMTP server deals with all SMTP protocol related mess, but let you decide on your own (through a configuration file which is a true Pliant program) what messages you will accept or reject, and where your're going to store them or forward them.

If you expect a ready to use SMTP server, you need both the Pliant SMTP server and a sample /etc/pliant/mail or /pliant_security/mail file (see samples below).


The simplest way to start Pliant SMTP server is to type in the following command at the shell prompt:

pliant module /pliant/protocol/smtp/server.pli command smtp_server

If everything works fine, you should get a message:
SMTP server is running on TCP port 25.
and the program should not stop.
If the program stoped (you get back to the prompt), you probably have another SMTP server already running, or your TCP/IP layer is not configured properly at operating system level. On a Unix system, you may also not be able to start the SMTP server if you don't have 'root' rights.

The Pliant confidential configurations files can be stored in /pliant_security/ or /etc/pliant/ directory (these paths refer to the operating system root, not to Pliant root).
The default access control files for the SMTP server is named mail.
The access control control file is a pliant program that decides if the submitted mail is accepted, and where it must be stored.

This is a sample control file that you could store in /pliant_security/mail or /etc/pliant/mail:

constant mycorp_domain "mycorp.com"
constant mycorp_ip "10.0.0.0/255.0.0.0"
constant mycorp_mails_path "/mycorp/mail/"
if stage=stage_to
  if (to parse any:(var Str user) "@" any:(var Str domain)) and domain=mycorp_domain
    # the mail is for a user inside our domain
    if (file_query mycorp_mails_path+user+"/" standard)=defined and user<>"forward" and user<>"archive"
      # the mailbox directory exists   
      store mycorp_mails_path+user+"/"
      # we also have a mail archives directory
      archive mycorp_mails_path+"archive/"+(string received_on:year)+(right (string received_on:month) 2 "0")+"/"+(right (string received_on:day) 2 "0")+"/"
    else
      reject "There is no "+to+" mailbox here"
  else
    # the mail is for a user outside our domain
    if (ip is_inside_ip_domain mycorp_ip) or (ip is_inside_ip_domain "127.0.0.0/255.255.255.0")
      # the client was in our domain, so we are not an open relay
      forward mycorp_mails_path+"forward/"
    else
      reject "This is not an open relay"

The control function is called saveral times while the client provides informations to the server.If the mail has several recipients, the control function will be called several times with stage=stage_to.
stage_open The TCP connection has been etablished but no information has been sent or received yet.
stage_helo The SMTP server sent the welcome message, and the client answered through a 'HELO' command.
stage_from The SMTP server is trying to send a new mail: it provided the 'MAIL FROM' command.
stage_to It also provided the 'RCPT TO' command.
stage_header The header of the message has been received by the SMTP server.
stage_body All the message has been received by the SMTP server: if we don't reject, then the client will assume that we accepted the message.
Please notice that 'stage_helo' and 'stage_from' may never be executed because if the client does not provide it's identity and the message has no sender.

These are the variables and instructions that you may use in the messages filter function:
variable minimal stage meaning
stage The current stage, so tells you which variables are meaningfull.
ip stage_open The IP address of the client.
name stage_helo The name provided by the client through HELO SMTP protocol instruction.
received_on stage_open The date and time the SMTP client started sending the message.
mailfrom stage_from The sender mailbox as provided through the MAIL FROM SMTP protocol instruction.
A sample value is: Mr Somebody <somebody@somewhere.com>
from stage_from The sender stripped mailbox.
A sample value is: somebody@somewhere.com
mailto stage_to The target mailbox as provided through the RCPT TO SMTP protocol instruction.
A sample value is: Mr Somebody <somebody@somewhere.com>
to stage_to The recipient stripped mailbox.
A sample value is: somebody@somewhere.com
hidden_to stage_header The list of all the recipients that are not listed in the message header.
This field type is 'List' and each element in the list has 'Str' type.
data stage_header / stage_body The stream containing the message.
At stage=stage_header, only the mail header has been received, but at stage=stage_body, all the mail has been received.
store path The mail will be stored in the provided path.
The path is generally the path of the recipient user mailbox.
archive path Same as 'store', but the path is one where several mailboxes are replicated for later searching.
exclude path Do not store the mail in the provided path.This enables to forbid mails from or to some confidential mailboxes to be stored in archives.
reject message Reject the mail with message being the one line explanation sent with the error code to the SMTP client.

server.pli contains the part of the SMTP server that will receive incoming mails and store them in mailboxes or forward queues.
forward.pli contains the part of the SMTP server that will forward messages in send queues.

The current status of the SMTP server is described in the SMTP server section of the Pliant overall project.