Mailfromd |
|
General-Purpose Mail Filter |
Sergey Poznyakoff |
Mailfromd Manual (split by node): | ? |
mailfromd
with Sendmail. This chapter assumes you are familiar with Sendmail configuration in
general and with Milter configuration directives in particular. It
concentrates only on issues, specific for mailfromd
.
To prepare Sendmail
to communicate with
mailfromd
you need first to set up the milter port.
This is done with INPUT_MAIL_FILTER
statement in your
Sendmail
file:
INPUT_MAIL_FILTER(`mailfrom', `S=unix:/usr/local/var/mailfromd/mailfrom') |
Make sure that the value of ‘S’ matches the value of
listen
statement in your ‘mailfromd.conf’ file
(see section listen). Notice, however, that they
may not be literally the same, because listen
allows to
specify socket address in various formats, whereas Sendmail's ‘S’
accepts only milter format.
If you prefer to fiddle directly with ‘sendmail.cf’ file, use this statement instead:
Xmailfrom, S=unix:/usr/local/var/mailfromd/mailfrom |
If you are using Sendmail version 8.14.0 or newer, you may skip to
the end of this section. These versions implement newer Milter
protocol that enables mailfromd
to negotiate with the
MTA the macros it needs for each state.
Older versions of Sendmail do not offer this feature. For Sendmail
versions prior to 8.14.0, you need to manually configure
Sendmail
to export macros you need in your
mailfromd.mf
file. The simplest way to do so is using
rc.mailfromd
script, introduced in the previous chapter.
Run it with macros
command line argument and copy its output to
your ‘sendmail.mc’ configuration file:
$ rc.mailfromd macros |
If you prefer to work with ‘sendmail.cf’ directly, use ‘-c’ (‘--cf’) command line option:
$ rc.mailfromd macros -c |
Finally, if you use other mailfromd script file than that already installed (for example, you are preparing a new configuration while the old one is still being used in production environment), give its name in the command line:
$ rc.mailfromd macros newscript.mf
# or:
$ rc.mailfromd macros -c newscript.mf
|
If you use this method, you can skip the rest of this chapter. However, if you are a daring sort of person and prefer to do everything manually, follow the instructions below.
First of all you need to build a list of macros used by handlers in
your ‘mailfromd.mf’ file. You can obtain it running
mailfromd --dump-macros
. This will display all macros used
in your handlers, grouped by handler name, for example:
envfrom i, f, {client_addr} envrcpt f, {client_addr}, {rcpt_addr} |
Now, modify confMILTER_MACROS_handler
macros in your
‘mc’ file. Here, handler means the uppercase name of the
mailfromd
handler you want to export macros to, i.e. the
first word on each line of the above mailfromd --dump-macros
output. Notice, that in addition to these macros, you should
also export the macro i
for the very first handler
(rc.mailfromd macros
takes care of it automatically, but you
preferred to do everything yourself...) It is necessary in
order for mailfromd
to include ‘Message-ID’ in its log
messages (see Message-ID).
For example, given the above macros listing, which corresponds to our sample configuration (see section Example of a Filter Script File), the ‘sendmail.mc’ snippet will contain:
define(`confMILTER_MACROS_ENVFROM',dnl confMILTER_MACROS_ENVFROM `, i, f, {client_addr}') define(`confMILTER_MACROS_ENVRCPT',dnl confMILTER_MACROS_ENVRCPT `, f, {client_addr}, {rcpt_addr}') |
Special attention should be paid to s
macro
(‘HELO’ domain name). In Sendmail
versions up to
8.13.7 (at least) it is available only to helo
handler. If you
wish to make it available elsewhere you will need to use the method
described in HELO Domain
Now, if you are a really daring person and prefer to do everything manually and to hack your ‘sendmail.cf’ file directly, you certainly don't need any advices. Nonetheless, here's how the two statements above could look in this case:
O Milter.macros.envfrom=i, {auth_type}, {auth_authen}, \ {auth_ssf}, {auth_author}, {mail_mailer}, {mail_host}, \ {mail_addr} ,{mail_addr}, {client_addr}, f O Milter.macros.envrcpt={rcpt_mailer}, {rcpt_host}, \ {rcpt_addr} ,i, f, {client_addr} |
Mailfromd Manual (split by node): | ? |
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.