Ключевые слова:mail, sendmail, m4, (найти похожие документы)
From: Georg Wagner
Subject: Конфигурация sendmail'а с помощью m4 макросов (eng)
Configuring sendmail 8.9 with m4-macros
29. November 1999
There exist two possibilities to configure sendmail: the first is to
edit the sendmail.cf file directly, the second to use a m4-macro file.
Most people - including me - are using both methods depending on the
their know how. Recently I took the effort to get a single point for
applying my changes to the configuration of sendmail: the m4-macro
I am using a dialup-account to connect to my ISP. My provider's domain
is datacomm.ch whereas my domain at home is internal.ch with a
192.168.x.x-network; the machine has the name mymachine. I will refer
to my local username as login. My username at the ISP is g.wagner.
This means my internal address is firstname.lastname@example.org and my
external address is email@example.com.
2 Configuring sendmail
First change to the directory ../cf/cf and create a copy of
# cp generic.bsd4.4.mc mymachine.mc
Before you start editing your newly created file, some possible
pitfalls with the macro language m4 should be mentioned:
* m4 uses forward- and backward-quotes
* The #-character does not have a special meaning to m4. If you are
writing a comment you should do it in the following way:
# `your comment here'
to prevent the possible interpretation of some words in your
comment as a macro.
2.1 Structure of the mc-file
The mc-file has the following structure:
2.2 Basic entries in mymachine.mc
After the header you should have the entries below the line with
These entries are already sufficient to get a simple forwarding
The first problem I want to solve, is to masquerade the internal
username and the internal domain.
Add the lines
in front of the line with MAILER(local). Now you have to populate the
makemap hash /etc/mail/user.db < ./user
where the file user contains lines like:
login:mailname firstname.lastname@example.org> 9
2.4 Anti-Spam measures
Since version 8.9 of sendmail the default is not to (ab)use your
machine as mail relay. This is also the reason for the
relay_entire_domain entry in Section 2.2.
To allow your mail to be relayed at your provider's mailserver add a
Using the acess database
If you want to maintain a spammer database of your own you can use the
FEATURE(access_db, hash -o /etc/mail/access.db)dnl
Add this entry between the DOMAIN and MAILER directives. Be sure to
create the access database using the commands:
/usr/sbin/makemap hash access.db < ./access
Where access is a file which you fill with lines like:
Using the Realtime Blackhole List
As alternative, if you don't want to maintain your own access
database, you can use the Realtime Blackhole list. If you don't know
what the Realtime Blackhole list is, have a look at
http://maps.vix.com/rbl. This is the simplest mechanism for
blocking spam. Just add the line:
to your mymachine.mc file.
Setting the privacy flags
Don't allow remote user to ask for any informations on your smtp port:
3 Generating and Installing the sendmail.cf-file
You should now have a mymachine.mc file containing the lines:
With the following commands you can change your current sendmail
m4 ../m4/cf.m4 mymachine.mc > mymachine.cf
cp /etc/sendmail.cf /etc/sendmail.cf.old
cp mymachine.cf /etc/sendmail.cf
ps -aux| grep sendmail
kill -HUP <PID>
I am not responsible if you spoil your configuration in applying the
described actions to your sendmail configuration. Make backups of
every file before you start. The mc-file was tested on my private
machine and seams to be working so far.
If you have any remarks, corrections or additions please send them to