Contents
What`s that? qmail-spp adds plugin support to qmail`s SMTP daemon (qmail-smtpd). It`s written entirely in C using native qmail libraries, so it does not create any dependencies.
1. history
Why should I use it? qmail-spp has been written because currently there is no common way of enhancing qmail-smtpd`s functionality apart of patches which usually are not compatible one with other and require recompilation. In addition, qmail-spp gives you possibility of enhancing your mail server in any language, so you can easily integrate it with anything you want.
How does it work? Plugins are external programs which are executed after processing SMTP command, but just before accepting it by qmail - this lets you to add extra checks on commands` arguments before accepting it - for instance you can check envelope recipient address against your "black list". Plugins can be written in any language, because they are independent programs. They: should not read anything from standard input, can print commands on standard output, should print all errors to standard error (they are logged), should not exit with error code 120. All required data (as HELO host, last RCPT address, etc.) can be retrieved from environmental variables.
Which SMTP commands can be enhanced this way? HELO/EHLO, MAIL, RCPT, DATA and (if supported) AUTH. There is also one pseudo-event triggered just after client connection. Regarding DATA: you can't run plugins which filter message content, you can only do something else than standard 354 go ahead - this may be useful for e.g. greylisting.
What environmental variables are set by qmail-spp? Name Description SMTPHELOHOST argument of 'HELO/EHLO' command SMTPMAILFROM argument of 'MAIL' command SMTPRCPTTO argument of last 'RCPT' command SMTPRCPTCOUNT how many times has 'RCPT' command been accepted SMTPRCPTCOUNTALL as above, but counts all issued 'RCPT' commands SMTPRCPTHOSTSOK rcpthosts check was successful (1) or not (0) Remark for SMTPRCPTCOUNT* variables: SMTPRCPTCOUNT is incremented after accepting the recipient by your plugin, and SMTPRCPTCOUNTALL is incremented before asking the plugin if the recipient should be accepted. This means that usually you will observe SMTPRCPTCOUNT=0 and SMTPRCPTCOUNTALL=1 in your plugin after first RCPT command. And if SMTP AUTH is supported: Name Description SMTPAUTHUSER user name of authorized SMTP client SMTPAUTHMETHOD used SMTP authorization method You should probably also take a look at http://cr.yp.to/ucspi-tcp/environment.html if you use tcpserver (from ucspi-tcp package). What environmental variables can I use to control qmail-spp? Name Description NOSPP if set, qmail-spp won't run in this session SPPCONFFILE if set, specifies alternative configuration file (instead of standard "control/smtpplugins")