"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "doc/mailfromd.info-1" between
mailfromd-8.11.tar.xz and mailfromd-8.12.tar.xz

About: Mailfromd is a general-purpose mail filtering daemon for Sendmail, Postfix and MeTA1 (interfaces with the MTA using Milter or PMilter protocols).

mailfromd.info-1  (mailfromd-8.11.tar.xz):mailfromd.info-1  (mailfromd-8.12.tar.xz)
File: mailfromd.info, Node: Top, Next: Preface, Up: (dir) File: mailfromd.info, Node: Top, Next: Preface, Up: (dir)
Mailfromd Mailfromd
********* *********
This edition of the 'Mailfromd Manual', last updated 15 February 2021, This edition of the 'Mailfromd Manual', last updated 23 July 2021,
documents 'mailfromd' Version 8.11. documents 'mailfromd' Version 8.12.
* Menu: * Menu:
* Preface:: Short description of this manual; brief * Preface:: Short description of this manual; brief
history and acknowledgments. history and acknowledgments.
* Intro:: Introduction to Mailfromd. * Intro:: Introduction to Mailfromd.
* Building:: Building the Package. * Building:: Building the Package.
* Tutorial:: Mailfromd Tutorial. * Tutorial:: Mailfromd Tutorial.
* MFL:: The Mail Filtering Language. * MFL:: The Mail Filtering Language.
* Library:: The MFL Library Functions. * Library:: The MFL Library Functions.
skipping to change at line 178 skipping to change at line 178
* scope of visibility:: * scope of visibility::
* import:: Require and Import * import:: Require and Import
The MFL Library Functions The MFL Library Functions
* Macro access:: * Macro access::
* String transformation:: * String transformation::
* String manipulation:: * String manipulation::
* String formatting:: * String formatting::
* Character Type:: * Character Type::
* I/O functions::
* Filtering functions::
* Email processing functions:: * Email processing functions::
* Envelope modification functions:: * Envelope modification functions::
* Header modification functions:: * Header modification functions::
* Body Modification Functions:: * Body Modification Functions::
* Message modification queue:: * Message modification queue::
* Mail header functions:: * Mail header functions::
* Mail body functions:: * Mail body functions::
* EOM Functions:: * EOM Functions::
* Current Message Functions:: * Current Message Functions::
* Mailbox functions:: * Mailbox functions::
* Message functions:: * Message functions::
* Quarantine functions:: * Quarantine functions::
* SMTP Callout functions:: * SMTP Callout functions::
* Compatibility Callout functions:: * Compatibility Callout functions::
* Internet address manipulation functions:: * Internet address manipulation functions::
* DNS functions:: * DNS functions::
* Geolocation functions:: * Geolocation functions::
* Database functions:: * Database functions::
* I/O functions::
* System functions:: * System functions::
* Passwd functions:: * Passwd functions::
* Sieve Interface:: * Sieve Interface::
* Interfaces to Third-Party Programs:: * Interfaces to Third-Party Programs::
* Rate limiting functions:: * Rate limiting functions::
* Greylisting functions:: * Greylisting functions::
* Special test functions:: * Special test functions::
* Mail Sending Functions:: * Mail Sending Functions::
* Blacklisting Functions:: * Blacklisting Functions::
* SPF Functions:: * SPF Functions::
* DKIM:: * DKIM::
* Sockmaps:: * Sockmaps::
* NLS Functions:: * NLS Functions::
* Syslog Interface:: * Syslog Interface::
* Debugging Functions:: * Debugging Functions::
Filtering functions
* Filters::
Message Functions Message Functions
* Header functions:: * Header functions::
* Message body functions:: * Message body functions::
* MIME functions:: * MIME functions::
* Message digest functions:: * Message digest functions::
Interfaces to Third-Party Programs Interfaces to Third-Party Programs
* SpamAssassin:: * SpamAssassin::
skipping to change at line 597 skipping to change at line 602
This manual is written using Texinfo, the GNU documentation formatting This manual is written using Texinfo, the GNU documentation formatting
language. The same set of Texinfo source files is used to produce both language. The same set of Texinfo source files is used to produce both
the printed and online versions of the documentation. This section the printed and online versions of the documentation. This section
briefly documents the typographical conventions used in this manual. briefly documents the typographical conventions used in this manual.
Examples you would type at the command line are preceded by the Examples you would type at the command line are preceded by the
common shell primary prompt, '$'. The command itself is printed 'in common shell primary prompt, '$'. The command itself is printed 'in
this font', and the output it produces 'in this font', for example: this font', and the output it produces 'in this font', for example:
$ mailfromd --version $ mailfromd --version
mailfromd (mailfromd 8.11) mailfromd (mailfromd 8.12)
In the text, the command names are printed 'like this', command line In the text, the command names are printed 'like this', command line
options are displayed in 'this font'. Some notions are emphasized _like options are displayed in 'this font'. Some notions are emphasized _like
this_, and if a point needs to be made strongly, it is done *this way*. this_, and if a point needs to be made strongly, it is done *this way*.
The first occurrence of a new term is usually its "definition" and The first occurrence of a new term is usually its "definition" and
appears in the same font as the previous occurrence of "definition" in appears in the same font as the previous occurrence of "definition" in
this sentence. File names are indicated like this: '/path/to/ourfile'. this sentence. File names are indicated like this: '/path/to/ourfile'.
The variable names are represented LIKE THIS, keywords and fragments The variable names are represented LIKE THIS, keywords and fragments
of program text are written in 'this font'. of program text are written in 'this font'.
skipping to change at line 823 skipping to change at line 828
B. GNU adns library, version 1.5.1 or newer. B. GNU adns library, version 1.5.1 or newer.
GNU adns is an advanced DNS client library. The recent GNU adns is an advanced DNS client library. The recent
version can be downloaded from version can be downloaded from
<http://www.chiark.greenend.org.uk/~ian/adns/adns.tar.gz>. <http://www.chiark.greenend.org.uk/~ian/adns/adns.tar.gz>.
Visit <http://www.gnu.org/software/adns>, for more Visit <http://www.gnu.org/software/adns>, for more
information. information.
C. A DBM library. 'Mailfromd' is able to link with any flavor of C. A DBM library. 'Mailfromd' is able to link with any flavor of
DBM supported by GNU mailutils. As of version 8.11 it will DBM supported by GNU mailutils. As of version 8.12 it will
refuse to build without DBM. By default, 'configure' will try refuse to build without DBM. By default, 'configure' will try
to find the best implementation installed on your machine to find the best implementation installed on your machine
(preference is given to Berkeley DB) and will use it. You (preference is given to Berkeley DB) and will use it. You
can, however, explicitly specify which implementation you want can, however, explicitly specify which implementation you want
to use. To do so, use the '--with-dbm' configure option. Its to use. To do so, use the '--with-dbm' configure option. Its
argument specifies the "type" of database to use. It must be argument specifies the "type" of database to use. It must be
one of the types supported by GNU mailutils. At the time of one of the types supported by GNU mailutils. At the time of
this writing, these are: this writing, these are:
bdb bdb
skipping to change at line 906 skipping to change at line 911
Main daemon. *Note mailfromd: Invocation. Main daemon. *Note mailfromd: Invocation.
'PREFIX/etc/mailfromd.mf' 'PREFIX/etc/mailfromd.mf'
Default main filter script file. It is installed only if it Default main filter script file. It is installed only if it
is not already there. Thus, if you are upgrading to a newer is not already there. Thus, if you are upgrading to a newer
version of 'mailfromd', your old script file will be preserved version of 'mailfromd', your old script file will be preserved
with all your changes. with all your changes.
*Note MFL::, for a description of the mail filtering language. *Note MFL::, for a description of the mail filtering language.
'PREFIX/share/mailfromd/8.11/*.mf' 'PREFIX/share/mailfromd/8.12/*.mf'
MFL modules. *Note Modules::. MFL modules. *Note Modules::.
'PREFIX/info/mailfromd.info*' 'PREFIX/info/mailfromd.info*'
Documentation files. Documentation files.
'PREFIX/bin/mtasim' 'PREFIX/bin/mtasim'
MTA simulator program for testing 'mailfromd' scripts. *Note MTA simulator program for testing 'mailfromd' scripts. *Note
mtasim::. mtasim::.
'PREFIX/sbin/pmult' 'PREFIX/sbin/pmult'
skipping to change at line 2203 skipping to change at line 2208
Some 'mailfromd' functions use DBM databases to save their persistent Some 'mailfromd' functions use DBM databases to save their persistent
state data. Each database has a unique "identifier", and is assigned state data. Each database has a unique "identifier", and is assigned
several pieces of information for its maintenance: the database "file several pieces of information for its maintenance: the database "file
name" and the "expiration period", i.e. the time after which a record name" and the "expiration period", i.e. the time after which a record
is considered expired. is considered expired.
To obtain the list of available databases along with their To obtain the list of available databases along with their
preconfigured settings, run 'mailfromd --show-defaults'. You will see preconfigured settings, run 'mailfromd --show-defaults'. You will see
an output similar to this: an output similar to this:
version: 8.11 version: 8.12
script file: /etc/mailfromd.mf script file: /etc/mailfromd.mf
preprocessor: /usr/bin/m4 -s preprocessor: /usr/bin/m4 -s
user: mail user: mail
statedir: /var/run/mailfromd statedir: /var/run/mailfromd
socket: unix:/var/run/mailfromd/mailfrom socket: unix:/var/run/mailfromd/mailfrom
pidfile: /var/run/mailfromd/mailfromd.pid pidfile: /var/run/mailfromd/mailfromd.pid
default syslog: blocking default syslog: blocking
supported databases: gdbm, bdb supported databases: gdbm, bdb
default database type: bdb default database type: bdb
optional features: GeoIP optional features: GeoIP
skipping to change at line 2240 skipping to change at line 2245
* Database Formats:: * Database Formats::
* Basic Database Operations:: * Basic Database Operations::
* Database Maintenance:: * Database Maintenance::
File: mailfromd.info, Node: Database Formats, Next: Basic Database Operations, Up: Databases File: mailfromd.info, Node: Database Formats, Next: Basic Database Operations, Up: Databases
3.15.1 Database Formats 3.15.1 Database Formats
----------------------- -----------------------
The version 8.11 runs the following database types (or "formats"): The version 8.12 runs the following database types (or "formats"):
'cache' 'cache'
"Cache database" keeps the information about external emails, "Cache database" keeps the information about external emails,
obtained using sender verification functions (*note Checking Sender obtained using sender verification functions (*note Checking Sender
Address::). The key entry to this database is an email address or Address::). The key entry to this database is an email address or
EMAIL:SENDER-IP string, for addresses checked using strict EMAIL:SENDER-IP string, for addresses checked using strict
verification. The data its stores for each key are: verification. The data its stores for each key are:
1. Address validity. This field can be either 'success' or 1. Address validity. This field can be either 'success' or
'not_found', meaning the address is confirmed to exists or it 'not_found', meaning the address is confirmed to exists or it
skipping to change at line 3175 skipping to change at line 3180
RUNTIME ERROR near FILE:LINE: TEXT RUNTIME ERROR near FILE:LINE: TEXT
where FILE:LINE indicates approximate source file location where the where FILE:LINE indicates approximate source file location where the
error occurred and TEXT gives the textual description of the error. error occurred and TEXT gives the textual description of the error.
Fatal runtime errors Fatal runtime errors
-------------------- --------------------
Fatal runtime errors are caused by a condition that is impossible to fix Fatal runtime errors are caused by a condition that is impossible to fix
at run time. For version 8.11 these are: at run time. For version 8.12 these are:
Not enough memory Not enough memory
There is not enough memory for the execution of the program. Try There is not enough memory for the execution of the program. Try
to make more memory available for 'mailfromd' or to reduce its to make more memory available for 'mailfromd' or to reduce its
memory requirements by rewriting your filter script. memory requirements by rewriting your filter script.
Out of stack space; increase #pragma stacksize Out of stack space; increase #pragma stacksize
Heap overrun; increase #pragma stacksize Heap overrun; increase #pragma stacksize
memory chunk too big to fit into heap memory chunk too big to fit into heap
These errors are reported when there is not enough space left on These errors are reported when there is not enough space left on
skipping to change at line 3398 skipping to change at line 3403
prog envfrom prog envfrom
do do
echo "X is %x" echo "X is %x"
done done
Does '%x' in 'echo' refers to the variable or to the constant? The Does '%x' in 'echo' refers to the variable or to the constant? The
correct answer is 'to the variable'. When executed, this code will correct answer is 'to the variable'. When executed, this code will
print 'X is X'. print 'X is X'.
As of version 8.11, 'mailfromd' will always print a diagnostic As of version 8.12, 'mailfromd' will always print a diagnostic
message whenever it stumbles upon a variable having the same name as a message whenever it stumbles upon a variable having the same name as a
previously defined constant or vice versa. The resolution of such name previously defined constant or vice versa. The resolution of such name
clashes is described in detail in *Note variable--constant shadowing::. clashes is described in detail in *Note variable--constant shadowing::.
Future versions of the program may provide a non-ambiguous way of Future versions of the program may provide a non-ambiguous way of
referring to variables and constants from literal strings. referring to variables and constants from literal strings.
File: mailfromd.info, Node: MFL, Next: Library, Prev: Tutorial, Up: Top File: mailfromd.info, Node: MFL, Next: Library, Prev: Tutorial, Up: Top
4 Mail Filtering Language 4 Mail Filtering Language
skipping to change at line 3491 skipping to change at line 3496
The quotes around FILE in the second form quotes are optional. The quotes around FILE in the second form quotes are optional.
Both forms are equivalent if FILE is an absolute file name. Both forms are equivalent if FILE is an absolute file name.
Otherwise, the first form will look for FILE in the "include search Otherwise, the first form will look for FILE in the "include search
path". The second one will look for it in the current working directory path". The second one will look for it in the current working directory
first, and, if not found there, in the include search path. first, and, if not found there, in the include search path.
The default include search path is: The default include search path is:
1. 'PREFIX/share/mailfromd/8.11/include' 1. 'PREFIX/share/mailfromd/8.12/include'
2. 'PREFIX/share/mailfromd/include' 2. 'PREFIX/share/mailfromd/include'
3. '/usr/share/mailfromd/include' 3. '/usr/share/mailfromd/include'
4. '/usr/local/share/mailfromd/include' 4. '/usr/local/share/mailfromd/include'
Where PREFIX is the installation prefix. Where PREFIX is the installation prefix.
New directories can be appended in front of it using '-I' New directories can be appended in front of it using '-I'
('--include') command line option, or 'include-path' configuration ('--include') command line option, or 'include-path' configuration
statement (*note include-path: conf-base.). statement (*note include-path: conf-base.).
For example, invoking For example, invoking
$ mailfromd -I/var/mailfromd -I/com/mailfromd $ mailfromd -I/var/mailfromd -I/com/mailfromd
creates the following include search path creates the following include search path
1. '/var/mailfromd' 1. '/var/mailfromd'
2. '/com/mailfromd' 2. '/com/mailfromd'
3. 'PREFIX/share/mailfromd/8.11/include' 3. 'PREFIX/share/mailfromd/8.12/include'
4. 'PREFIX/share/mailfromd/include' 4. 'PREFIX/share/mailfromd/include'
5. '/usr/share/mailfromd/include' 5. '/usr/share/mailfromd/include'
6. '/usr/local/share/mailfromd/include' 6. '/usr/local/share/mailfromd/include'
Along with '#include', there is also a special form '#include_once', Along with '#include', there is also a special form '#include_once',
that has the same syntax: that has the same syntax:
#include_once <FILE> #include_once <FILE>
#include_once "FILE" #include_once "FILE"
skipping to change at line 4137 skipping to change at line 4142
File: mailfromd.info, Node: Built-in constants, Up: Constants File: mailfromd.info, Node: Built-in constants, Up: Constants
4.8.1 Built-in constants 4.8.1 Built-in constants
------------------------ ------------------------
Several constants are built into the MFL compiler. To discern them from Several constants are built into the MFL compiler. To discern them from
user-defined ones, their names start and end with two underscores user-defined ones, their names start and end with two underscores
('__'). ('__').
The following constants are defined in 'mailfromd' version 8.11: The following constants are defined in 'mailfromd' version 8.12:
-- Built-in constant: string __file__ -- Built-in constant: string __file__
Expands to the name of the current source file. Expands to the name of the current source file.
-- Built-in constant: string __function__ -- Built-in constant: string __function__
Expands to the name of the current lexical context, i.e. the Expands to the name of the current lexical context, i.e. the
function or handler name. function or handler name.
-- Built-in constant: string __git__ -- Built-in constant: string __git__
This built-in constant is defined for alpha versions only. Its This built-in constant is defined for alpha versions only. Its
skipping to change at line 4341 skipping to change at line 4346
* Menu: * Menu:
* Predefined variables:: * Predefined variables::
File: mailfromd.info, Node: Predefined variables, Up: Variables File: mailfromd.info, Node: Predefined variables, Up: Variables
4.9.1 Predefined Variables 4.9.1 Predefined Variables
-------------------------- --------------------------
Several variables are predefined. In 'mailfromd' version 8.11 these Several variables are predefined. In 'mailfromd' version 8.12 these
are: are:
-- Variable: Predefined Variable number cache_used -- Variable: Predefined Variable number cache_used
This variable is set by 'stdpoll' and 'strictpoll' built-ins (and, This variable is set by 'stdpoll' and 'strictpoll' built-ins (and,
consequently, by the 'on poll' statement). Its value is '1' if the consequently, by the 'on poll' statement). Its value is '1' if the
function used the cached data instead of directly polling the host, function used the cached data instead of directly polling the host,
and '0' if the polling took place. *Note SMTP Callout functions::. and '0' if the polling took place. *Note SMTP Callout functions::.
You can use this variable to make your reject message more You can use this variable to make your reject message more
informative for the remote party. The common paradigm is to define informative for the remote party. The common paradigm is to define
skipping to change at line 5009 skipping to change at line 5014
function body, the following construct is used: function body, the following construct is used:
$(EXPR) $(EXPR)
where EXPR is any valid MFL expression, evaluating to a number N. This where EXPR is any valid MFL expression, evaluating to a number N. This
construct refers to the value of Nth actual parameter from the variable construct refers to the value of Nth actual parameter from the variable
argument list. Parameters are numbered from '1', so the first variable argument list. Parameters are numbered from '1', so the first variable
parameter is '$(1)', and the last one is '$($# - NM - NO)', where NM and parameter is '$(1)', and the last one is '$($# - NM - NO)', where NM and
NO are numbers of mandatory and optional parameters to the function. NO are numbers of mandatory and optional parameters to the function.
The construct '$(N)' where 1 <= N <= 9 can also be written as '$N'.
For example, the function below prints all its arguments: For example, the function below prints all its arguments:
func pargs (string text, ...) func pargs (string text, ...)
do do
echo "text=%text" echo "text=%text"
loop for number i 1, loop for number i 1,
while i <= $# - 1, while i < $# - @text,
set i i + 1 set i i + 1
do do
echo "arg %i=" . $(i) echo "arg %i=" . $(i)
done done
done done
Note the loop limits. The last variable argument has number '$# - 1', Note how the ordinal number operator is used to compute the upper limit.
because the function takes one mandatory argument.
The FUNCTION-BODY is any list of valid 'mailfromd' statements. In The FUNCTION-BODY is any list of valid 'mailfromd' statements. In
addition to the statements discussed below (*note Statements::) it can addition to the statements discussed below (*note Statements::) it can
also contain the 'return' statement, which is used to return a value also contain the 'return' statement, which is used to return a value
from the function. The syntax of the return statement is from the function. The syntax of the return statement is
return VALUE return VALUE
As an example of this, consider the following code snippet that As an example of this, consider the following code snippet that
defines the function 'sum' to return a sum of its two arguments: defines the function 'sum' to return a sum of its two arguments:
skipping to change at line 5223 skipping to change at line 5229
return 0 return 0
fi fi
fi fi
# never reached # never reached
done done
---------- Footnotes ---------- ---------- Footnotes ----------
(1) Notice that these are intended for educational purposes and do (1) Notice that these are intended for educational purposes and do
not necessarily coincide with the actual definitions of these functions not necessarily coincide with the actual definitions of these functions
in Mailfromd version 8.11. in Mailfromd version 8.12.
File: mailfromd.info, Node: Expressions, Next: Shadowing, Prev: Functions, U p: MFL File: mailfromd.info, Node: Expressions, Next: Shadowing, Prev: Functions, U p: MFL
4.14 Expressions 4.14 Expressions
================ ================
Expressions are language constructs, that evaluate to a value, that can Expressions are language constructs, that evaluate to a value, that can
subsequently be echoed, tested in a conditional statement, assigned to a subsequently be echoed, tested in a conditional statement, assigned to a
variable or passed to a function. variable or passed to a function.
skipping to change at line 5845 skipping to change at line 5851
Header Actions Header Actions
.............. ..............
Header manipulation actions provide basic means to add, delete or modify Header manipulation actions provide basic means to add, delete or modify
the message RFC 2822 headers. the message RFC 2822 headers.
'add NAME STRING' 'add NAME STRING'
Add the header NAME with the value STRING. E.g.: Add the header NAME with the value STRING. E.g.:
add "X-Seen-By" "Mailfromd 8.11" add "X-Seen-By" "Mailfromd 8.12"
(notice argument quoting) (notice argument quoting)
'replace NAME STRING' 'replace NAME STRING'
The same as 'add', but if the header NAME already exists, it will The same as 'add', but if the header NAME already exists, it will
be removed first, for example: be removed first, for example:
replace "X-Last-Processor" "Mailfromd 8.11" replace "X-Last-Processor" "Mailfromd 8.12"
'delete NAME' 'delete NAME'
Delete the header named NAME: Delete the header named NAME:
delete "X-Envelope-Date" delete "X-Envelope-Date"
These actions impose some restrictions. First of all, their first These actions impose some restrictions. First of all, their first
argument must be a literal string (not a variable or expression). argument must be a literal string (not a variable or expression).
Secondly, there is no way to select a particular header instance to Secondly, there is no way to select a particular header instance to
delete or replace, which may be necessary to properly handle multiple delete or replace, which may be necessary to properly handle multiple
skipping to change at line 6193 skipping to change at line 6199
* Catch and Throw:: * Catch and Throw::
File: mailfromd.info, Node: Built-in Exceptions, Next: User-defined Exceptions , Up: Exceptions File: mailfromd.info, Node: Built-in Exceptions, Next: User-defined Exceptions , Up: Exceptions
4.19.1 Built-in Exceptions 4.19.1 Built-in Exceptions
-------------------------- --------------------------
The first 20 exception numbers are reserved for "built-in exceptions". The first 20 exception numbers are reserved for "built-in exceptions".
These are declared in module 'status.mf'. The following table These are declared in module 'status.mf'. The following table
summarizes all built-in exception types implemented by 'mailfromd' summarizes all built-in exception types implemented by 'mailfromd'
version 8.11. Exceptions are listed in lexicographic order. version 8.12. Exceptions are listed in lexicographic order.
'e_badmmq' -- Exception: e_badmmq
The called function cannot finish its task because an uncompatible The called function cannot finish its task because an uncompatible
message modification function was called at some point before it. message modification function was called at some point before it.
For details, *note MMQ and dkim_sign::. For details, *note MMQ and dkim_sign::.
'e_dbfailure' -- Exception: e_dbfailure
General database failure. For example, the database cannot be General database failure. For example, the database cannot be
opened. This exception can be signaled by any function that opened. This exception can be signaled by any function that
queries any DBM database. queries any DBM database.
'e_divzero' -- Exception: e_divzero
Division by zero. Division by zero.
'e_exists' -- Exception: e_exists
This exception is emitted by 'dbinsert' built-in if the requested This exception is emitted by 'dbinsert' built-in if the requested
key is already present in the database (*note dbinsert: Database key is already present in the database (*note dbinsert: Database
functions.). functions.).
'e_eof' -- Exception: e_eof
Function reached end of file while reading. *Note I/O functions::, Function reached end of file while reading. *Note I/O functions::,
for a description of functions that can signal this exception. for a description of functions that can signal this exception.
'e_failure' -- Exception: e_failure
'failure' -- Exception: failure
'e_failure'
A general failure has occurred. In particular, this exception is A general failure has occurred. In particular, this exception is
signaled by DNS lookup functions when any permanent failure occurs. signaled by DNS lookup functions when any permanent failure occurs.
This exception can be signaled by any DNS-related function This exception can be signaled by any DNS-related function
('hasmx', 'poll', etc.) or operation ('mx matches'). ('hasmx', 'poll', etc.) or operation ('mx matches').
'e_format' -- Exception: e_format
Invalid input format. This exception is signaled if input data to Invalid input format. This exception is signaled if input data to
a function are improperly formatted. In version 8.11 it is a function are improperly formatted. In version 8.12 it is
signaled by 'message_burst' function if its input message is not signaled by 'message_burst' function if its input message is not
formatted according to RFC 934. *Note Message digest functions::. formatted according to RFC 934. *Note Message digest functions::.
'e_invcidr' -- Exception: e_ilseq
Illegal byte sequence. Signaled when a string cannot be converted
between character sets because a sequence of bytes was encountered
that is not defined for the source character set or cannot be
represented in the destination character set.
*Note MIME decoding::, for details.
-- Exception: e_invcidr
Invalid CIDR notation. This is signaled by 'match_cidr' function Invalid CIDR notation. This is signaled by 'match_cidr' function
when its second argument is not a valid CIDR. when its second argument is not a valid CIDR.
'e_invip' -- Exception: e_invip
Invalid IP address. This is signaled by 'match_cidr' function when Invalid IP address. This is signaled by 'match_cidr' function when
its first argument is not a valid IP address. its first argument is not a valid IP address.
'e_invtime' -- Exception: e_invtime
Invalid time interval specification. It is signaled by 'interval' Invalid time interval specification. It is signaled by 'interval'
function if its argument is not a valid time interval (*note time function if its argument is not a valid time interval (*note time
interval specification::). interval specification::).
'e_io' -- Exception: e_io
An error occurred during the input-output operation. *Note I/O An error occurred during the input-output operation. *Note I/O
functions::, for a description of functions that can signal this functions::, for a description of functions that can signal this
exception. exception.
'e_macroundef' -- Exception: e_macroundef
A Sendmail macro is undefined. A Sendmail macro is undefined.
'e_noresolve' -- Exception: e_noresolve
The argument of a DNS-related function cannot be resolved to host The argument of a DNS-related function cannot be resolved to host
name or IP address. Currently only 'ismx' (*note ismx::) raises name or IP address. Currently only 'ismx' (*note ismx::) raises
this exception. this exception.
'e_range' -- Exception: e_range
The supplied argument is outside the allowed range. This is The supplied argument is outside the allowed range. This is
signalled, for example, by 'substring' function (*note signalled, for example, by 'substring' function (*note
substring::). substring::).
'e_regcomp' -- Exception: e_regcomp
Regular expression cannot be compiled. This can happen when a Regular expression cannot be compiled. This can happen when a
regular expression (a right-hand argument of a 'matches' operator) regular expression (a right-hand argument of a 'matches' operator)
is built at the runtime and the produced string is an invalid is built at the runtime and the produced string is an invalid
regex. regex.
'e_ston_conv' -- Exception: e_ston_conv
String-to-number conversion failed. This can be signaled when a String-to-number conversion failed. This can be signaled when a
string is used in numeric context which cannot be converted to the string is used in numeric context which cannot be converted to the
numeric data type. For example: numeric data type. For example:
set x "10a" set x "10a"
if x / 2 if x / 2
... ...
The 'if' condition will signal 'ston_conv', since '10a' cannot be The 'if' condition will signal 'ston_conv', since '10a' cannot be
converted to a number. converted to a number.
'e_temp_failure' -- Exception: e_temp_failure
'temp_failure' -- Exception: temp_failure
'e_temp_failure'
A temporary failure has occurred. This can be signaled by A temporary failure has occurred. This can be signaled by
DNS-related functions or operations. DNS-related functions or operations.
'e_url' -- Exception: e_url
The supplied URL is invalid. *Note Interfaces to Third-Party The supplied URL is invalid. *Note Interfaces to Third-Party
Programs::. Programs::.
In addition to these, two symbols are defined that are not exception -- Exception: e_success
types in the strict sense of the world, but are provided to make writing -- Exception: success
filter scripts more convenient. These are 'success', meaning successful -- Exception: e_not_found
return from a function, and 'not_found', meaning that the required -- Exception: not_found
entity (e.g. domain name or email address) was not found. *Note Figure In addition to these, two symbols are defined that are not
4.1: figure-poll-wrapper, for an illustration on how these can be used. exception types in the strict sense of the world, but are provided
For consistency with other exception codes, these can be spelled as to make writing filter scripts more convenient. These are
'e_success' and 'e_not_found'. 'success', meaning successful return from a function, and
'not_found', meaning that the required entity (e.g. domain name or
email address) was not found. *Note Figure 4.1:
figure-poll-wrapper, for an illustration on how these can be used.
For consistency with other exception codes, these can be spelled as
'e_success' and 'e_not_found'.
File: mailfromd.info, Node: User-defined Exceptions, Next: Catch and Throw, P rev: Built-in Exceptions, Up: Exceptions File: mailfromd.info, Node: User-defined Exceptions, Next: Catch and Throw, P rev: Built-in Exceptions, Up: Exceptions
4.19.2 User-defined Exceptions 4.19.2 User-defined Exceptions
------------------------------ ------------------------------
You can define your own exception types using the 'dclex' statement: You can define your own exception types using the 'dclex' statement:
dclex TYPE dclex TYPE
skipping to change at line 7003 skipping to change at line 7020
Disables the external preprocessor. Disables the external preprocessor.
'--preprocessor=COMMAND' '--preprocessor=COMMAND'
Use COMMAND as external preprocessor. Be especially careful with Use COMMAND as external preprocessor. Be especially careful with
this option, because 'mailfromd' cannot verify whether COMMAND is this option, because 'mailfromd' cannot verify whether COMMAND is
actually some kind of a preprocessor or not. actually some kind of a preprocessor or not.
---------- Footnotes ---------- ---------- Footnotes ----------
(1) It is usually located in (1) It is usually located in
'/usr/local/share/mailfromd/8.11/include/pp-setup'. '/usr/local/share/mailfromd/8.12/include/pp-setup'.
(2) This is similar to GNU m4 '--prefix-builtin' options. This (2) This is similar to GNU m4 '--prefix-builtin' options. This
approach was chosen to allow for using non-GNU 'm4' implementations as approach was chosen to allow for using non-GNU 'm4' implementations as
well. well.
File: mailfromd.info, Node: Filter Script Example, Next: Reserved Words, Prev : Preprocessor, Up: MFL File: mailfromd.info, Node: Filter Script Example, Next: Reserved Words, Prev : Preprocessor, Up: MFL
4.23 Example of a Filter Script File 4.23 Example of a Filter Script File
==================================== ====================================
skipping to change at line 7233 skipping to change at line 7250
Any keyword beginning with a 'm4_' prefix is a reserved preprocessor Any keyword beginning with a 'm4_' prefix is a reserved preprocessor
symbol. symbol.
File: mailfromd.info, Node: Library, Next: Using MFL Mode, Prev: MFL, Up: To p File: mailfromd.info, Node: Library, Next: Using MFL Mode, Prev: MFL, Up: To p
5 The MFL Library Functions 5 The MFL Library Functions
*************************** ***************************
This chapter describes library functions available in Mailfromd version This chapter describes library functions available in Mailfromd version
8.11. For the simplicity of explanation, we use the word 'boolean' to 8.12. For the simplicity of explanation, we use the word 'boolean' to
indicate variables of numeric type that are used as boolean values. For indicate variables of numeric type that are used as boolean values. For
such variables, the term 'False' stands for the numeric 0, and 'True' such variables, the term 'False' stands for the numeric 0, and 'True'
for any non-zero value. for any non-zero value.
* Menu: * Menu:
* Macro access:: * Macro access::
* String transformation:: * String transformation::
* String manipulation:: * String manipulation::
* String formatting:: * String formatting::
* Character Type:: * Character Type::
* I/O functions::
* Filtering functions::
* Email processing functions:: * Email processing functions::
* Envelope modification functions:: * Envelope modification functions::
* Header modification functions:: * Header modification functions::
* Body Modification Functions:: * Body Modification Functions::
* Message modification queue:: * Message modification queue::
* Mail header functions:: * Mail header functions::
* Mail body functions:: * Mail body functions::
* EOM Functions:: * EOM Functions::
* Current Message Functions:: * Current Message Functions::
* Mailbox functions:: * Mailbox functions::
* Message functions:: * Message functions::
* Quarantine functions:: * Quarantine functions::
* SMTP Callout functions:: * SMTP Callout functions::
* Compatibility Callout functions:: * Compatibility Callout functions::
* Internet address manipulation functions:: * Internet address manipulation functions::
* DNS functions:: * DNS functions::
* Geolocation functions:: * Geolocation functions::
* Database functions:: * Database functions::
* I/O functions::
* System functions:: * System functions::
* Passwd functions:: * Passwd functions::
* Sieve Interface:: * Sieve Interface::
* Interfaces to Third-Party Programs:: * Interfaces to Third-Party Programs::
* Rate limiting functions:: * Rate limiting functions::
* Greylisting functions:: * Greylisting functions::
* Special test functions:: * Special test functions::
* Mail Sending Functions:: * Mail Sending Functions::
* Blacklisting Functions:: * Blacklisting Functions::
* SPF Functions:: * SPF Functions::
skipping to change at line 7839 skipping to change at line 7857
s s
The string argument is written to the output. If a precision is The string argument is written to the output. If a precision is
specified, no more than the number specified of characters are specified, no more than the number specified of characters are
written. written.
% %
A '%' is written. No argument is converted. The complete A '%' is written. No argument is converted. The complete
conversion specification is '%%'. conversion specification is '%%'.
File: mailfromd.info, Node: Character Type, Next: Email processing functions, Prev: String formatting, Up: Library File: mailfromd.info, Node: Character Type, Next: I/O functions, Prev: String formatting, Up: Library
5.5 Character Type 5.5 Character Type
================== ==================
These functions check whether all characters of STR fall into a certain These functions check whether all characters of STR fall into a certain
character class according to the 'C' ('POSIX') locale(1). 'True' (1) is character class according to the 'C' ('POSIX') locale(1). 'True' (1) is
returned if they do, 'false' (0) is returned otherwise. In the latter returned if they do, 'false' (0) is returned otherwise. In the latter
case, the global variable 'ctype_mismatch' is set to the index of the case, the global variable 'ctype_mismatch' is set to the index of the
first character that is outside of the character class (characters are first character that is outside of the character class (characters are
indexed from 0). indexed from 0).
skipping to change at line 7910 skipping to change at line 7928
-- Built-in Function: boolean isxdigit (string STR) -- Built-in Function: boolean isxdigit (string STR)
Checks for hexadecimal digits, i.e. one of '0', '1', '2', '3', Checks for hexadecimal digits, i.e. one of '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'A', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'A',
'B', 'C', 'D', 'E', 'F'. 'B', 'C', 'D', 'E', 'F'.
---------- Footnotes ---------- ---------- Footnotes ----------
(1) Support for other locales is planned for future versions. (1) Support for other locales is planned for future versions.
File: mailfromd.info, Node: Email processing functions, Next: Envelope modific File: mailfromd.info, Node: I/O functions, Next: Filtering functions, Prev: C
ation functions, Prev: Character Type, Up: Library haracter Type, Up: Library
5.6 Email processing functions.
===============================
-- Built-in Function: number email_map (string EMAIL)
Parses EMAIL and returns a bitmap, consisting of zero or more of
the following flags:
'EMAIL_MULTIPLE'
EMAIL has more than one email address.
'EMAIL_COMMENTS'
EMAIL has comment parts.
'EMAIL_PERSONAL'
EMAIL has personal part.
'EMAIL_LOCAL'
EMAIL has local part.
'EMAIL_DOMAIN'
EMAIL has domain part.
'EMAIL_ROUTE'
EMAIL has route part.
These constants are declared in the 'email.mf' module. The
function 'email_map' returns 0 if its argument is not a valid email
address.
-- Library Function: boolean email_valid (string EMAIL)
Returns 'True' (1) if EMAIL is a valid email address, consisting of
local and domain parts only. E.g.:
email_valid("gray@gnu.org") => 1
email_valid("gray") => 0
email_valid('"Sergey Poznyakoff <gray@gnu.org>') => 0
This function is defined in 'email.mf' (*note Modules::).
File: mailfromd.info, Node: Envelope modification functions, Next: Header modi
fication functions, Prev: Email processing functions, Up: Library
5.7 Envelope Modification Functions
===================================
Envelope modification functions set sender and add or delete recipient
addresses from the message envelope. This allows MFL scripts to
redirect messages to another addresses.
-- Built-in Function: void set_from (string EMAIL [, string ARGS])
Sets envelope sender address to EMAIL, which must be a valid email
address. Optional ARGS supply arguments to ESMTP 'MAIL FROM'
command.
-- Built-in Function: void rcpt_add (string ADDRESS)
Add the e-mail ADDRESS to the envelope.
-- Built-in Function: void rcpt_delete (string ADDRESS)
Remove ADDRESS from the envelope.
The following example code uses these functions to implement a simple
alias-like capability:
prog envrcpt
do
string alias dbget(aliasdb, $1, "NULL", 1)
if alias != "NULL"
rcpt_delete($1)
rcpt_add(alias)
fi
done
File: mailfromd.info, Node: Header modification functions, Next: Body Modifica
tion Functions, Prev: Envelope modification functions, Up: Library
5.8 Header Modification Functions
=================================
There are two ways to modify message headers in a MFL script. First is
to use header actions, described in *note Actions::, and the second way
is to use message modification functions. Compared with the actions,
the functions offer a series of advantages. For example, using
functions you can construct the name of the header to operate upon (e.g.
by concatenating several arguments), something which is impossible when
using actions. Moreover, apart from three basic operations (add, modify
and remove), as supported by header actions, header functions allow to
insert a new header into a particular place.
-- Built-in Function: void header_add (string NAME, string VALUE)
Adds a header 'NAME: VALUE' to the message.
In contrast to the 'add' action, this function allows to construct
the header name using arbitrary MFL expressions.
-- Built-in Function: void header_add (string NAME, string VALUE,
number IDX)
This syntax is preserved for backward compatibility. It is
equivalent to 'header_insert', which see.
-- Built-in Function: void header_insert (string NAME, string VALUE,
number IDX)
This function inserts a header 'NAME: 'value'' at IDXth header
position in the internal list of headers maintained by the MTA.
That list contains headers added to the message either by the
filter or by the MTA itself, but not the headers included in the
message itself. Some of the headers in this list are conditional,
e.g. the ones added by the 'H?COND?' directive in 'sendmail.cf'.
MTA evaluates them after all header modifications have been done
and removes those of headers for which they yield false. This
means that the position at which the header added by
'header_insert' will appear in the final message will differ from
IDX.
-- Built-in Function: void header_delete (string NAME [, number INDEX])
Delete header NAME from the envelope. If INDEX is given, delete
INDEXth instance of the header NAME.
Notice the differences between this function and the 'delete'
action:
1. It allows to construct the header name, whereas 'delete'
requires it to be a literal string.
2. Optional INDEX argument allows to select a particular header
instance to delete.
-- Built-in Function: void header_replace (string NAME, string VALUE [,
number INDEX])
Replace the value of the header NAME with VALUE. If INDEX is
given, replace INDEXth instance of header NAME.
Notice the differences between this function and the 'replace'
action:
1. It allows to construct the header name, whereas 'replace'
requires it to be a literal string.
2. Optional INDEX argument allows to select a particular header
instance to replace.
-- Library Function: void header_rename (string NAME, string NEWNAME[,
number IDX])
Defined in the module 'header_rename.mf'.
Available only in the 'eom' handler.
Renames the IDXth instance of header NAME to NEWNAME. If IDX is
not given, assumes 1.
If the specified header or the IDX instance of it is not present in
the current message, the function silently returns. All other
errors cause run-time exception.
The position of the renamed header in the header list is not 5.6 I/O functions
preserved. =================
The example below renames 'Subject' header to 'X-Old-Subject':
require 'header_rename' MFL provides a set of functions for writing to disk files, pipes or
sockets and reading from them. The idea behind them is the same as in
most other programming languages: first you open the resource with a
call to 'open' which returns a "descriptor" i.e. an integer number
uniquely identifying the resource. Then you can write or read from it
using this descriptor. Finally, when the resource is no longer needed,
you can close it with a call to 'close'.
The number of available resource descriptors is limited. The default
limit is 1024. You can tailor it to your needs using the 'max-streams'
runtime configuration statement. *Note max-streams: conf-runtime, for a
detailed description.
-- Built-in Function: number open (string NAME)
The NAME argument specifies the name of a resource to open and the
access rights you need to have on it. The function returns a
descriptor of the opened stream, which can subsequently be used as
an argument to other I/O operations.
First symbols of NAME determine the type of the resource to be
opened and the access mode:
'>'
The rest of NAME is a name of a file. Open the file for
read-write access. If the file exists, truncate it to zero
length, otherwise create the file.
'>>'
The rest of NAME is a name of a file. Open the file for
appending (writing at end of file). The file is created if it
does not exist.
'|'
Treat the rest of NAME as the command name and its arguments.
Run this command and open its standard input for writing. The
standard error is closed before launching the program. This
can be altered by using the following versions of this
construct:
|2>null: COMMAND
Standard error is redirected to '/dev/null'.
|2>file:NAME COMMAND
Execute COMMAND with its standard error redirected to the
file NAME. If the file exists, it will be truncated.
|2>>file:NAME COMMAND
Standard error of the COMMAND is appended to the file
NAME. If file does not exist, it will be created.
The '|2>null:' construct described above is a shortcut
for
|2>>file:/dev/null COMMAND
|2>syslog:FACILITY[.PRIORITY] COMMAND
Standard error is redirected to the given syslog FACILITY
and, optionally, PRIORITY. If the latter is omitted,
'LOG_ERR' is assumed.
Valid values for FACILITY are: 'user', 'daemon', 'auth',
'authpriv', 'mail', and 'local0' through 'local7'. Valid
values for PRIORITY are: 'emerg', 'alert', 'crit', 'err',
'warning', 'notice', 'info', 'debug'. Both FACILITY and
PRIORITY may be given in upper, lower or mixed cases.
Notice, that no whitespace characters are allowed between '|'
and '2>'.
'|<'
Treat the rest of NAME as the command name and its arguments.
Run this command with its stdin closed and stdout open for
reading.
The standard error is treated as described above (see '|').
'|&'
Treat the rest of NAME as the command name and its arguments.
Run this command and set up for two-way communication with it,
i.e writes to the descriptor returned by 'open' will send data
to the program's standard input, reads from the descriptor
will get data from the program's standard output.
The standard error is treated as described above (see '|').
For example, the following redirects it to syslog
'mail.debug':
|&2>syslog:mail.debug COMMAND
'@'
Treat the rest of NAME as the URL of a socket to connect to.
Valid URL forms are described in *note milter port
specification::.
If none of these prefixes is used, NAME is treated as a name of an
existing file and 'open' will attempt to open this file for
reading.
The 'open' function will signal exception 'e_failure' if it is
unable to open the resource or get the required access to it.
-- Built-in Function: number spawn (string CMD [, number IN, number
OUT, number ERR])
Runs the supplied command CMD. The syntax of the CMD is the same
as for the NAME argument to 'open' (see above), which begins with
'|', excepting that the '|' sign is optional. That is:
spawn("/bin/cat")
has exactly the same effect as
open("|/bin/cat")
Optional arguments specify file stream descriptors to be used for
the program standard input, output and error streams,
correspondingly. If supplied, these should be the values returned
by a previous call to 'open' or 'tempfile'. The value '-1' means
no redirection.
The example below starts the 'awk' program with a simple expression
as its argument and redirects the content of the file '/etc/passwd'
to its standard input. The returned stream descriptor is bound to
the command's standard output (see the description of '|<' prefix
above). The standard error is closed:
number fd spawn("<awk -F: '{print $1}'", open("/etc/passwd"))
-- Built-in Function: void close (number RD)
The argument RD is a resource descriptor returned by a previous
call to 'open'. The function 'close' closes the resource and
deallocates any memory associated with it.
'close' will signal 'e_range' exception if RD lies outside of
allowed range of resource descriptors. *Note max-streams:
conf-runtime.
Notice that you are not required to close resources opened by 'open'.
Any unclosed resource will be closed automatically upon the termination
of the filtering program.
-- Built-in Function: void shutdown (number RD, number HOW)
This function causes all or part of a full-duplex connection to be
closed. The RD must be either a socket descriptor (returned by
'open(@...)') or a two-way pipe socket descriptor (returned by
'open(|&...)'), otherwise the call to 'shutdown' is completely
equivalent to 'close'.
The 'how' argument identifies which part of the connection to shut
down:
SHUT_RD
Read connection. All further receptions will be disallowed.
SHUT_WR
Write connection. All further transmissions will be
disallowed.
SHUT_RDWR
Shut down both read and write parts.
-- Built-in Function: number tempfile ([string TMPDIR])
Creates a nameless temporary file and returns its descriptor.
Optional TMPDIR supplies the directory where to create the file,
instead of the default '/tmp'.
-- Built-in Function: void rewind (number RD)
Rewinds the stream identified by RD to its beginning.
-- Built-in Function: number copy (number DST, number SRC)
Copies all data from the stream SRC to DST. Returns number of
bytes copied.
The following functions provide basic read/write capabilities.
-- Built-in Function: void write (number RD, string STR [, number
SIZE])
Writes the string STR to the resource descriptor RD. If the SIZE
argument is given, writes this number of bytes.
The function will signal 'e_range' exception if RD lies outside of
allowed range of resource descriptors, and 'e_io' exception if an
I/O error occurs.
-- Built-in Function: void write_body (number RD, pointer BP , number
SIZE)
Write the body segment of length SIZE from pointer BP to the stream
RD. This function can be used only in 'prog body' (*note body
handler::). Its second and third arguments correspond exactly to
the parameters of the 'body' handler, so the following construct
writes the message body to the resource 'fd', which should have
been open prior to invoking the 'body' handler:
prog eom prog body
do do
header_rename("Subject", "X-Old-Subject") write_body(fd, $1, $2)
done done
-- Library Function: void header_prefix_all (string NAME [, string -- Built-in Function: string read (number RD, number N)
PREFIX]) Read and return N bytes from the resource descriptor RD.
Defined in the module 'header_rename.mf'.
Available only in the 'eom' handler.
Renames all headers named NAME by prefixing them with PREFIX. If
PREFIX is not supplied, removes all such headers.
All renamed headers will be placed in a continuous block in the
header list. The absolute position in the header list will change.
Relative ordering of renamed headers will be preserved.
-- Library Function: void header_prefix_pattern (string PATTERN, string
PREFIX)
Defined in the module 'header_rename.mf'. The function may signal the following exceptions:
Available only in the 'eom' handler.
Renames all headers with names matching PATTERN (in the sense of e_range
'fnmatch', *note fnmatches: Special comparisons.) by prefixing them RD lies outside of allowed range of resource descriptors.
with PREFIX. e_eof
End of file encountered.
e_io
An I/O error occurred.
All renamed headers will be placed in a continuous block in the -- Built-in Function: string getdelim (number RD, string DELIM)
header list. The absolute position in the header list will change. Read and return the next string terminated by DELIM from the
Relative ordering of renamed headers will be preserved. resource descriptor RD.
If called with one argument, removes all headers matching PATTERN. The terminating DELIM string will be removed from the return value.
For example, to prefix all headers beginning with 'X-Spamd-' with The function may signal the following exceptions:
an additional 'X-':
require 'header_rename' e_range
RD lies outside of allowed range of resource descriptors.
e_eof
End of file encountered.
e_io
An I/O error occurred.
prog eom -- Built-in Function: string getline (number RD)
do Read and return the next "line" from the resource descriptor RD. A
header_prefix_pattern("X-Spamd-*", "X-") line is any sequence of characters terminated with the default
done "line delimiter". The default delimiter is a property of RD, i.e.
different descriptors can have different line delimiters. The
File: mailfromd.info, Node: Body Modification Functions, Next: Message modific default value is '\n' (ASCII 10), and can be changed using the
ation queue, Prev: Header modification functions, Up: Library 'fd_set_delimiter' function (see below).
5.9 Body Modification Functions
===============================
Body modification is an experimental feature of MFL. The version 8.11 The function may signal the following exceptions:
provides only one function for that purpose.
-- Built-in Function: void replbody (string TEXT) e_range
Replace the body of the message with TEXT. Notice, that TEXT must RD lies outside of allowed range of resource descriptors.
not contain RFC 822 headers. See the previous section if you want e_eof
to manipulate message headers. End of file encountered.
e_io
An I/O error occurred.
Example: -- Built-in Function: void fd_set_delimiter (number FD, string DELIM)
Set new line delimiter for the descriptor FD, which must be in
opened state.
replbody("Body of this message has been removed by the mail filter." Default delimiter is a newline character (ASCII 10). The following
) example shows how to change it to CRLF sequence:
No restrictions are imposed on the format of TEXT. fd_set_delimiter(fd, "\r\n")
-- Built-in Function: void replbody_fd (number FD) -- Built-in Function: string fd_delimiter (number FD)
Replaces the body of the message with the content of the stream FD. Returns the line delimiter string for FD.
Use this function if the body is very big, or if it is returned by
an external program.
Notice that this function starts reading from the current position The following example shows how 'mailfromd' I/O functions can be used
in FD. Use 'rewind' if you wish to read from the beginning of the to automatically add IP addresses to an RBL zone:
stream.
The example below shows how to preprocess the body of the message set nsupdate_cmd
using external program '/usr/bin/mailproc', which is supposed to "/usr/bin/nsupdate -k /etc/bind/Kmail.+157+14657.private"
read the body from its standard input and write the processed text
to its standard output:
number fd # Temporary file descriptor func block_address(string addr)
do
number fd
string domain
prog data set fd open "|%nsupdate_cmd"
do
# Open the temporary file
set fd tempfile()
done
prog body set domain revip(addr) . ".rbl.myzone.come"
do write(fd, "prereq nxrrset %domain A\n"
# Write the body to it. "update add %domain 86400 A %addr\n\n"
write_body(fd, $1, $2) done
done
prog eom The function 'revip' is defined in *note revip::.
do
# Use the resulting stream as the stdin to the mailproc
# command and read the new body from its standard output.
rewind(fd)
replbody_fd(spawn("</usr/bin/mailproc", fd))
done
 End of changes. 72 change blocks. 
287 lines changed or deleted 326 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)