Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 28.82 KB | None | 0 0
  1. use strict;
  2.  
  3. # a minimalistic configuration file for amavisd-new with all necessary settings
  4. #
  5. #   see amavisd.conf-default for a list of all variables with their defaults;
  6. #   for more details see documentation in INSTALL, README_FILES/*
  7. #   and at http://www.ijs.si/software/amavisd/amavisd-new-docs.html
  8.  
  9.  
  10. # COMMONLY ADJUSTED SETTINGS:
  11.  
  12. # @bypass_virus_checks_maps = (1);  # controls running of anti-virus code
  13. # @bypass_spam_checks_maps  = (1);  # controls running of anti-spam code
  14. # $bypass_decode_parts = 1;         # controls running of decoders&dearchivers
  15.  
  16. $max_servers = 2;            # num of pre-forked children (2..30 is common), -m
  17. $daemon_user  = 'amavis';    # (no default;  customary: vscan or amavis), -u
  18. $daemon_group = 'amavis';    # (no default;  customary: vscan or amavis), -g
  19.  
  20. $mydomain = "ycsab.youcantspoilababy.org";  # = 'example.com';   # a convenient default for other settings
  21.  
  22. $MYHOME = '/var/spool/amavisd';   # a convenient default for other settings, -H
  23. $TEMPBASE = "$MYHOME/tmp";   # working directory, needs to exist, -T
  24. $ENV{TMPDIR} = $TEMPBASE;    # environment variable TMPDIR, used by SA, etc.
  25. $QUARANTINEDIR = undef;      # -Q
  26. # $quarantine_subdir_levels = 1;  # add level of subdirs to disperse quarantine
  27. # $release_format = 'resend';     # 'attach', 'plain', 'resend'
  28. # $report_format  = 'arf';        # 'attach', 'plain', 'resend', 'arf'
  29.  
  30. # $daemon_chroot_dir = $MYHOME;   # chroot directory or undef, -R
  31.  
  32. $db_home   = "$MYHOME/db";        # dir for bdb nanny/cache/snmp databases, -D
  33. # $helpers_home = "$MYHOME/var";  # working directory for SpamAssassin, -S
  34. $lock_file = "/var/run/amavisd/amavisd.lock";  # -L
  35. $pid_file  = "/var/run/amavisd/amavisd.pid";   # -P
  36. #NOTE: create directories $MYHOME/tmp, $MYHOME/var, $MYHOME/db manually
  37.  
  38. $log_level = 0;              # verbosity 0..5, -d
  39. $log_recip_templ = undef;    # disable by-recipient level-0 log entries
  40. $do_syslog = 1;              # log via syslogd (preferred)
  41. $syslog_facility = 'mail';   # Syslog facility as a string
  42.            # e.g.: mail, daemon, user, local0, ... local7
  43.  
  44. $enable_db = 1;              # enable use of BerkeleyDB/libdb (SNMP and nanny)
  45. # $enable_zmq = 1;           # enable use of ZeroMQ (SNMP and nanny)
  46. $nanny_details_level = 2;    # nanny verbosity: 1: traditional, 2: detailed
  47. $enable_dkim_verification = 1;  # enable DKIM signatures verification
  48. $enable_dkim_signing = 1;    # load DKIM signing code, keys defined by dkim_key
  49.  
  50. @local_domains_maps = 1;
  51.  
  52. @mynetworks = qw( 127.0.0.0/8 [::1] [FE80::]/10 [FEC0::]/10
  53.                   10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 );
  54.  
  55. $unix_socketname = "/var/run/amavisd/amavisd.sock";  # amavisd-release or amavis-milter
  56.                # option(s) -p overrides $inet_socket_port and $unix_socketname
  57.  
  58. $inet_socket_port = [10024, 10026, 9998];
  59. # $inet_socket_port = [10024, 9998];
  60.  
  61. $policy_bank{'MYNETS'} = {   # mail originating from @mynetworks
  62.   originating => 1,  # is true in MYNETS by default, but let's make it explicit
  63.   os_fingerprint_method => undef,  # don't query p0f for internal clients
  64.   allow_disclaimers => 1, # enables disclaimer insertion if available
  65. };
  66.  
  67. # it is up to MTA to re-route mail from authenticated roaming users or
  68. # from internal hosts to a dedicated TCP port (such as 10026) for filtering
  69. $interface_policy{'10026'} = 'ORIGINATING';
  70.  
  71. $policy_bank{'ORIGINATING'} = {  # mail supposedly originating from our users
  72.   originating => 1,  # declare that mail was submitted by our smtp client
  73.   allow_disclaimers => 1,  # enables disclaimer insertion if available
  74.   # notify administrator of locally originating malware
  75.   virus_admin_maps => ["virusalert\@$mydomain"],
  76.   spam_admin_maps  => ["virusalert\@$mydomain"],
  77.   warnbadhsender   => 1,
  78.   # forward to a smtpd service providing DKIM signing service
  79.   # forward_method => 'smtp:[127.0.0.1]:10027',
  80.   # force MTA conversion to 7-bit (e.g. before DKIM signing)
  81.   smtpd_discard_ehlo_keywords => ['8BITMIME'],
  82.   # bypass_banned_checks_maps => [1],  # allow sending any file names and types
  83.   terminate_dsn_on_notify_success => 0,  # don't remove NOTIFY=SUCCESS option
  84. };
  85.  
  86. $interface_policy{'SOCK'} = 'AM.PDP-SOCK'; # only applies with $unix_socketname
  87.  
  88. # Use with amavis-release over a socket or with Petr Rehor's amavis-milter.c
  89. # (with amavis-milter.c from this package or old amavis.c client use 'AM.CL'):
  90. $policy_bank{'AM.PDP-SOCK'} = {
  91.   protocol => 'AM.PDP',
  92.   auth_required_release => 0,  # do not require secret_id for amavisd-release
  93. };
  94.  
  95. $sa_tag_level_deflt  = 2.0;  # add spam info headers if at, or above that level
  96. $sa_tag2_level_deflt = 6.2;  # add 'spam detected' headers at that level
  97. $sa_kill_level_deflt = 6.9;  # triggers spam evasive actions (e.g. blocks mail)
  98. $sa_dsn_cutoff_level = 10;   # spam level beyond which a DSN is not sent
  99. $sa_crediblefrom_dsn_cutoff_level = 18; # likewise, but for a likely valid From
  100. # $sa_quarantine_cutoff_level = 25; # spam level beyond which quarantine is off
  101. $penpals_bonus_score = 8;    # (no effect without a @storage_sql_dsn database)
  102. $penpals_threshold_high = $sa_kill_level_deflt;  # don't waste time on hi spam
  103. $bounce_killer_score = 100;  # spam score points to add for joe-jobbed bounces
  104.  
  105. $sa_mail_body_size_limit = 400*1024; # don't waste time on SA if mail is larger
  106. $sa_local_tests_only = 0;    # only tests which do not require internet access?
  107.  
  108. # @lookup_sql_dsn =
  109. #   ( ['DBI:mysql:database=mail;host=127.0.0.1;port=3306', 'user1', 'passwd1'],
  110. #     ['DBI:mysql:database=mail;host=host2', 'username2', 'password2'],
  111. #     ["DBI:SQLite:dbname=$MYHOME/sql/mail_prefs.sqlite", '', ''] );
  112. # @storage_sql_dsn = @lookup_sql_dsn;  # none, same, or separate database
  113. # @storage_redis_dsn = ( {server=>'127.0.0.1:6379', db_id=>1} );
  114. # $redis_logging_key = 'amavis-log';
  115. # $redis_logging_queue_size_limit = 300000;  # about 250 MB / 100000
  116.  
  117. # $timestamp_fmt_mysql = 1; # if using MySQL *and* msgs.time_iso is TIMESTAMP;
  118. #   defaults to 0, which is good for non-MySQL or if msgs.time_iso is CHAR(16)
  119.  
  120. $virus_admin               = undef;                    # notifications recip.
  121.  
  122. $mailfrom_notify_admin     = undef;                    # notifications sender
  123. $mailfrom_notify_recip     = undef;                    # notifications sender
  124. $mailfrom_notify_spamadmin = undef;                    # notifications sender
  125. $mailfrom_to_quarantine = ''; # null return path; uses original sender if undef
  126.  
  127. @addr_extension_virus_maps      = ('virus');
  128. @addr_extension_banned_maps     = ('banned');
  129. @addr_extension_spam_maps       = ('spam');
  130. @addr_extension_bad_header_maps = ('badh');
  131. # $recipient_delimiter = '+';  # undef disables address extensions altogether
  132. # when enabling addr extensions do also Postfix/main.cf: recipient_delimiter=+
  133.  
  134. $path = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/usr/bin:/bin';
  135. # $dspam = 'dspam';
  136.  
  137. $MAXLEVELS = 14;
  138. $MAXFILES = 3000;
  139. $MIN_EXPANSION_QUOTA =      100*1024;  # bytes  (default undef, not enforced)
  140. $MAX_EXPANSION_QUOTA = 500*1024*1024;  # bytes  (default undef, not enforced)
  141.  
  142. $sa_spam_subject_tag = '***Spam*** ';
  143. $defang_virus  = 1;  # MIME-wrap passed infected mail
  144. $defang_banned = 0;  # MIME-wrap passed mail containing banned name
  145. # for defanging bad headers only turn on certain minor contents categories:
  146. $defang_by_ccat{CC_BADH.",3"} = 1;  # NUL or CR character in header
  147. $defang_by_ccat{CC_BADH.",5"} = 1;  # header line longer than 998 characters
  148. $defang_by_ccat{CC_BADH.",6"} = 1;  # header field syntax error
  149.  
  150.  
  151. # OTHER MORE COMMON SETTINGS (defaults may suffice):
  152.  
  153. # $myhostname = 'host.example.com';  # must be a fully-qualified domain name!
  154.  
  155. # $notify_method  = 'smtp:[127.0.0.1]:10025';
  156. # $forward_method = 'smtp:[127.0.0.1]:10025';  # set to undef with milter!
  157.  
  158. #$final_virus_destiny      = D_DISCARD;
  159. #$final_banned_destiny     = D_BOUNCE;
  160. #$final_spam_destiny       = D_DISCARD;  #!!!  D_DISCARD / D_REJECT
  161. #$final_bad_header_destiny = D_BOUNCE;
  162. # $bad_header_quarantine_method = undef;
  163.  
  164. # $os_fingerprint_method = 'p0f:*:2345';  # to query p0f-analyzer.pl
  165.  
  166. ## hierarchy by which a final setting is chosen:
  167. ##   policy bank (based on port or IP address) -> *_by_ccat
  168. ##   *_by_ccat (based on mail contents) -> *_maps
  169. ##   *_maps (based on recipient address) -> final configuration value
  170.  
  171.  
  172. # SOME OTHER VARIABLES WORTH CONSIDERING (see amavisd.conf-default for all)
  173.  
  174. # $warnbadhsender,
  175. # $warnvirusrecip, $warnbannedrecip, $warnbadhrecip, (or @warn*recip_maps)
  176. #
  177. # @bypass_virus_checks_maps, @bypass_spam_checks_maps,
  178. # @bypass_banned_checks_maps, @bypass_header_checks_maps,
  179. #
  180. # @virus_lovers_maps, @spam_lovers_maps,
  181. # @banned_files_lovers_maps, @bad_header_lovers_maps,
  182. #
  183. # @blacklist_sender_maps, @score_sender_maps,
  184. #
  185. # $clean_quarantine_method, $virus_quarantine_to, $banned_quarantine_to,
  186. # $bad_header_quarantine_to, $spam_quarantine_to,
  187. #
  188. # $defang_bad_header, $defang_undecipherable, $defang_spam
  189.  
  190.  
  191. # REMAINING IMPORTANT VARIABLES ARE LISTED HERE BECAUSE OF LONGER ASSIGNMENTS
  192.  
  193. @keep_decoded_original_maps = (new_RE(
  194.   qr'^MAIL$',                # let virus scanner see full original message
  195.   qr'^MAIL-UNDECIPHERABLE$', # same as ^MAIL$ if mail is undecipherable
  196.   qr'^(ASCII(?! cpio)|text|uuencoded|xxencoded|binhex)'i,
  197. # qr'^Zip archive data',     # don't trust Archive::Zip
  198. ));
  199.  
  200.  
  201. $banned_filename_re = new_RE(
  202.  
  203. ### BLOCKED ANYWHERE
  204. # qr'^UNDECIPHERABLE$',  # is or contains any undecipherable components
  205.   qr'^\.(exe-ms|dll)$',                   # banned file(1) types, rudimentary
  206. # qr'^\.(exe|lha|cab|dll)$',              # banned file(1) types
  207.  
  208. ### BLOCK THE FOLLOWING, EXCEPT WITHIN UNIX ARCHIVES:
  209. # [ qr'^\.(gz|bz2)$'             => 0 ],  # allow any in gzip or bzip2
  210.   [ qr'^\.(rpm|cpio|tar)$'       => 0 ],  # allow any in Unix-type archives
  211.  
  212.   qr'.\.(pif|scr)$'i,                     # banned extensions - rudimentary
  213. # qr'^\.zip$',                            # block zip type
  214.  
  215. ### BLOCK THE FOLLOWING, EXCEPT WITHIN ARCHIVES:
  216. # [ qr'^\.(zip|rar|arc|arj|zoo)$'=> 0 ],  # allow any within these archives
  217.  
  218.   qr'^application/x-msdownload$'i,        # block these MIME types
  219.   qr'^application/x-msdos-program$'i,
  220.   qr'^application/hta$'i,
  221.  
  222. # qr'^message/partial$'i,         # rfc2046 MIME type
  223. # qr'^message/external-body$'i,   # rfc2046 MIME type
  224.  
  225. # qr'^(application/x-msmetafile|image/x-wmf)$'i,  # Windows Metafile MIME type
  226. # qr'^\.wmf$',                            # Windows Metafile file(1) type
  227.  
  228.   # block certain double extensions in filenames
  229.   qr'^(?!cid:).*\.[^./]*[A-Za-z][^./]*\.\s*(exe|vbs|pif|scr|bat|cmd|com|cpl|dll)[.\s]*$'i,
  230.  
  231. # qr'\{[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}\}?'i, # Class ID CLSID, strict
  232. # qr'\{[0-9a-z]{4,}(-[0-9a-z]{4,}){0,7}\}?'i, # Class ID extension CLSID, loose
  233.  
  234.   qr'.\.(exe|vbs|pif|scr|cpl)$'i,             # banned extension - basic
  235. # qr'.\.(exe|vbs|pif|scr|cpl|bat|cmd|com)$'i, # banned extension - basic+cmd
  236. # qr'.\.(ade|adp|app|bas|bat|chm|cmd|com|cpl|crt|emf|exe|fxp|grp|hlp|hta|
  237. #        inf|ini|ins|isp|js|jse|lib|lnk|mda|mdb|mde|mdt|mdw|mdz|msc|msi|
  238. #        msp|mst|ocx|ops|pcd|pif|prg|reg|scr|sct|shb|shs|sys|vb|vbe|vbs|vxd|
  239. #        wmf|wsc|wsf|wsh)$'ix,                # banned extensions - long
  240. # qr'.\.(asd|asf|asx|url|vcs|wmd|wmz)$'i,     # consider also
  241. # qr'.\.(ani|cur|ico)$'i,                 # banned cursors and icons filename
  242. # qr'^\.ani$',                            # banned animated cursor file(1) type
  243. # qr'.\.(mim|b64|bhx|hqx|xxe|uu|uue)$'i,  # banned extension - WinZip vulnerab.
  244. );
  245. # See http://support.microsoft.com/default.aspx?scid=kb;EN-US;q262631
  246. # and http://www.cknow.com/vtutor/vtextensions.htm
  247.  
  248.  
  249. # ENVELOPE SENDER SOFT-WHITELISTING / SOFT-BLACKLISTING
  250.  
  251. @score_sender_maps = ({ # a by-recipient hash lookup table,
  252.                         # results from all matching recipient tables are summed
  253.  
  254. # ## per-recipient personal tables  (NOTE: positive: black, negative: white)
  255. # '[email protected]'  => [{'[email protected]' => 10.0}],
  256. # '[email protected]'  => [{'.ebay.com'                 => -3.0}],
  257. #                           '.cleargreen.com'           => -5.0}],
  258.  
  259.   ## site-wide opinions about senders (the '.' matches any recipient)
  260.   '.' => [  # the _first_ matching sender determines the score boost
  261.  
  262.    new_RE(  # regexp-type lookup table, just happens to be all soft-blacklist
  263.     [qr'^(bulkmail|offers|cheapbenefits|earnmoney|foryou)@'i         => 5.0],
  264.     [qr'^(greatcasino|investments|lose_weight_today|market\.alert)@'i=> 5.0],
  265.     [qr'^(money2you|MyGreenCard|new\.tld\.registry|opt-out|opt-in)@'i=> 5.0],
  266.     [qr'^(optin|saveonlsmoking2002k|specialoffer|specialoffers)@'i   => 5.0],
  267.     [qr'^(stockalert|stopsnoring|wantsome|workathome|yesitsfree)@'i  => 5.0],
  268.     [qr'^(your_friend|greatoffers)@'i                                => 5.0],
  269.     [qr'^(inkjetplanet|marketopt|MakeMoney)\d*@'i                    => 5.0],
  270.    ),
  271.  
  272. #  read_hash("/var/amavis/sender_scores_sitewide"),
  273.  
  274.    { # a hash-type lookup table (associative array)
  275.      '[email protected]'                        => -3.0,
  276.      '[email protected]'              => -3.0,
  277.      '[email protected]'                    => -3.0,
  278.      '[email protected]'                  => -3.0,
  279.      'securityfocus.com'                      => -3.0,
  280.      '[email protected]'       => -3.0,
  281.      '[email protected]'      => -3.0,
  282.      '[email protected]'      => -3.0,
  283.      '[email protected]'=> -3.0,
  284.      '[email protected]' => -3.0,
  285.      'spamassassin.apache.org'                => -3.0,
  286.      '[email protected]'   => -3.0,
  287.      '[email protected]'        => -3.0,
  288.      '[email protected]'     => -3.0,
  289.      '[email protected]'   => -3.0,
  290.      '[email protected]' => -3.0,
  291.      '[email protected]'                => -3.0,
  292.      '[email protected]'               => -3.0,
  293.      '[email protected]'                  => -3.0,
  294.      '[email protected]'          => -3.0,
  295.      '[email protected]'           => -3.0,
  296.      '[email protected]'       => -3.0,
  297.      '[email protected]'          => -3.0,
  298.      '[email protected]'            => -3.0,
  299.      '[email protected]'            => -3.0,
  300.      '[email protected]'                => -5.0,
  301.      '[email protected]'           => -3.0,
  302.      'returns.groups.yahoo.com'               => -3.0,
  303.      '[email protected]'           => -3.0,
  304.      lc('[email protected]')    => -3.0,
  305.      lc('[email protected]') => -5.0,
  306.  
  307.      # soft-blacklisting (positive score)
  308.      '[email protected]'                     =>  3.0,
  309.      '.example.net'                           =>  1.0,
  310.  
  311.    },
  312.   ],  # end of site-wide tables
  313. });
  314.  
  315.  
  316. @decoders = (
  317.   ['mail', \&do_mime_decode],
  318. # [[qw(asc uue hqx ync)], \&do_ascii],  # not safe
  319.   ['F',    \&do_uncompress, ['unfreeze', 'freeze -d', 'melt', 'fcat'] ],
  320.   ['Z',    \&do_uncompress, ['uncompress', 'gzip -d', 'zcat'] ],
  321.   ['gz',   \&do_uncompress, 'gzip -d'],
  322.   ['gz',   \&do_gunzip],
  323.   ['bz2',  \&do_uncompress, 'bzip2 -d'],
  324.   ['xz',   \&do_uncompress,
  325.            ['xzdec', 'xz -dc', 'unxz -c', 'xzcat'] ],
  326.   ['lzma', \&do_uncompress,
  327.            ['lzmadec', 'xz -dc --format=lzma',
  328.             'lzma -dc', 'unlzma -c', 'lzcat', 'lzmadec'] ],
  329.   ['lrz',  \&do_uncompress,
  330.            ['lrzip -q -k -d -o -', 'lrzcat -q -k'] ],
  331.   ['lzo',  \&do_uncompress, 'lzop -d'],
  332.   ['lz4',  \&do_uncompress, ['lz4c -d'] ],
  333.   ['rpm',  \&do_uncompress, ['rpm2cpio.pl', 'rpm2cpio'] ],
  334.   [['cpio','tar'], \&do_pax_cpio, ['pax', 'gcpio', 'cpio'] ],
  335.            # ['/usr/local/heirloom/usr/5bin/pax', 'pax', 'gcpio', 'cpio']
  336.   ['deb',  \&do_ar, 'ar'],
  337. # ['a',    \&do_ar, 'ar'],  # unpacking .a seems an overkill
  338.   ['rar',  \&do_unrar, ['unrar', 'rar'] ],
  339.   ['arj',  \&do_unarj, ['unarj', 'arj'] ],
  340.   ['arc',  \&do_arc,   ['nomarch', 'arc'] ],
  341.   ['zoo',  \&do_zoo,   ['zoo', 'unzoo'] ],
  342. # ['doc',  \&do_ole,   'ripole'],  # no ripole package so far
  343.   ['cab',  \&do_cabextract, 'cabextract'],
  344. # ['tnef', \&do_tnef_ext, 'tnef'],  # use internal do_tnef() instead
  345.   ['tnef', \&do_tnef],
  346. # ['lha',  \&do_lha,   'lha'],  # not safe, use 7z instead
  347. # ['sit',  \&do_unstuff, 'unstuff'],  # not safe
  348.   [['zip','kmz'], \&do_7zip,  ['7za', '7z'] ],
  349.   [['zip','kmz'], \&do_unzip],
  350.   ['7z',   \&do_7zip,  ['7zr', '7za', '7z'] ],
  351.   [[qw(gz bz2 Z tar)],
  352.            \&do_7zip,  ['7za', '7z'] ],
  353.   [[qw(xz lzma jar cpio arj rar swf lha iso cab deb rpm)],
  354.            \&do_7zip,  '7z' ],
  355.   ['exe',  \&do_executable, ['unrar','rar'], 'lha', ['unarj','arj'] ],
  356. );
  357. $sa_debug = 0;
  358. # Set hostname.
  359. $myhostname = "ycsab.youcantspoilababy.org";
  360.  
  361. # Set listen IP/PORT.
  362. $notify_method  = 'smtp:[127.0.0.1]:10025';
  363. $forward_method = 'smtp:[127.0.0.1]:10025';
  364.  
  365. @av_scanners = (
  366.     #### http://www.clamav.net/
  367.     ['ClamAV-clamd',
  368.     \&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamd.amavisd/clamd.socket"],
  369.     qr/\bOK$/, qr/\bFOUND$/,
  370.     qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
  371. );
  372.  
  373. @av_scanners_backup = (
  374.     ### http://www.clamav.net/   - backs up clamd or Mail::ClamAV
  375.     ['ClamAV-clamscan', 'clamscan',
  376.     "--stdout --disable-summary -r --tempdir=$TEMPBASE {}", [0], [1],
  377.     qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
  378. );
  379.  
  380. # Apply to mails which coming from internal networks or authenticated users.
  381. # mail supposedly originating from our users
  382. # $policy_bank{'MYUSERS'} = {
  383.     # # declare that mail was submitted by our smtp client
  384.     # originating => 1,
  385. #
  386.     # # enables disclaimer insertion if available
  387.     # allow_disclaimers => 1,
  388. #
  389.     # # notify administrator of locally originating malware
  390.     # virus_admin_maps => ["root\@$mydomain"],
  391.     # spam_admin_maps => [],
  392.     # bad_header_admin_maps => [],
  393.     # banned_admin_maps => ["root\@$mydomain"],
  394. #
  395.     # # notify sender of malware
  396.     # warnbadhsender => 0,
  397.     # warnbannedsender => 0,
  398. #
  399.     # # forward to a smtpd service providing DKIM signing service
  400.     # #forward_method => 'smtp:[127.0.0.1]:10027',
  401. #
  402.     # # force MTA conversion to 7-bit (e.g. before DKIM signing)
  403.     # smtpd_discard_ehlo_keywords => ['8BITMIME'],
  404. #
  405.     # # don't remove NOTIFY=SUCCESS option
  406.     # terminate_dsn_on_notify_success => 0,
  407. #
  408.     # # don't perform spam/virus/header check.
  409.     # #bypass_spam_checks_maps => [1],
  410.     # #bypass_virus_checks_maps => [1],
  411.     # #bypass_header_checks_maps => [1],
  412. #
  413.     # # allow sending any file names and types
  414.     # #bypass_banned_checks_maps => [1],
  415. #
  416.     # # Quarantine clean messages
  417.     # #clean_quarantine_method => 'sql:',
  418.     # #final_destiny_by_ccat => {CC_CLEAN, D_DISCARD},
  419. # };
  420.  
  421. #
  422. # Port used to release quarantined mails.
  423. #
  424. $interface_policy{'9998'} = 'AM.PDP-INET';
  425. $policy_bank{'AM.PDP-INET'} = {
  426.     protocol => 'AM.PDP',       # select Amavis policy delegation protocol
  427.     inet_acl => [qw( 127.0.0.1 [::1] )],    # restrict access to these IP addresses
  428.     auth_required_release => 1,    # 0 - don't require secret_id for amavisd-release
  429.     #log_level => 4,
  430.     #always_bcc_by_ccat => {CC_CLEAN, '[email protected]'},
  431. };
  432.  
  433. # Set default action.
  434. # Available actions: D_PASS, D_BOUNCE, D_REJECT, D_DISCARD.
  435. $final_virus_destiny      = D_DISCARD;
  436. $final_banned_destiny     = D_BOUNCE;
  437. $final_spam_destiny       = D_PASS;
  438. $final_bad_header_destiny = D_PASS;
  439.  
  440. #########################
  441. # Quarantine mails.
  442. #
  443.  
  444. # Where to store quarantined mail message:
  445. #   - 'local:spam-%i-%m', quarantine mail on local file system.
  446. #   - 'sql:', quarantine mail in SQL server specified in @storage_sql_dsn.
  447. #   - undef, do not quarantine mail.
  448.  
  449. # Bad header.
  450. $bad_header_quarantine_method = undef;
  451. #$bad_header_quarantine_method = 'sql:';
  452. #$bad_header_quarantine_to = 'bad-header-quarantine';
  453.  
  454. # SPAM.
  455. $spam_quarantine_method = undef;
  456. #$spam_quarantine_method = 'sql:';
  457. #$spam_quarantine_to = 'spam-quarantine';
  458.  
  459. # Virus
  460. $virus_quarantine_to     = 'virus-quarantine';
  461. $virus_quarantine_method = 'sql:';
  462.  
  463. # Banned
  464. $banned_files_quarantine_method = undef;
  465. #$banned_files_quarantine_method = 'sql:';
  466. #$banned_quarantine_to = 'banned-quarantine';
  467.  
  468. #########################
  469. # Quarantine CLEAN mails.
  470. # Don't forget to enable clean quarantine in policy bank 'MYUSERS'.
  471. #
  472. #$clean_quarantine_method = 'sql:';
  473. #$clean_quarantine_to = 'clean-quarantine';
  474.  
  475. $sql_allow_8bit_address = 1;
  476. $timestamp_fmt_mysql = 1;
  477.  
  478. # a string to prepend to Subject (for local recipients only) if mail could
  479. # not be decoded or checked entirely, e.g. due to password-protected archives
  480. #$undecipherable_subject_tag = '***UNCHECKED*** ';  # undef disables it
  481. $undecipherable_subject_tag = undef;
  482. # Hope to fix 'nested MAIL command' issue on high load server.
  483. $smtp_connection_cache_enable = 0;
  484.  
  485. # The default set of header fields to be signed can be controlled
  486. # by setting %signed_header_fields elements to true (to sign) or
  487. # to false (not to sign). Keys must be in lowercase, e.g.:
  488. # 0 -> off
  489. # 1 -> on
  490. $signed_header_fields{'received'} = 0;
  491. $signed_header_fields{'to'} = 1;
  492.  
  493. # Make sure it sings all inbound mails, avoid error log like this:
  494. # 'dkim: not signing inbound mail'.
  495. # $originating = 1;
  496.  
  497. # Add dkim_key here.
  498. dkim_key("youcantspoilababy.org", "dkim", "/var/lib/dkim/youcantspoilababy.org.pem");
  499.  
  500. # Note that signing mail for subdomains with a key of a parent
  501. # domain is treated by recipients as a third-party key, which
  502. # may 'hold less merit' in their eyes. If one has a choice,
  503. # it is better to publish a key for each domain (e.g. host1.a.cn)
  504. # if mail is really coming from it. Sharing a pem file
  505. # for multiple domains may be acceptable, so you don't need
  506. # to generate a different key for each subdomain, but you
  507. # do need to publish it in each subdomain. It is probably
  508. # easier to avoid sending addresses like host1.a.cn and
  509. # always use a parent domain (a.cn) in 'From:', thus
  510. # avoiding the issue altogether.
  511. #dkim_key("host1.youcantspoilababy.org", "dkim", "/var/lib/dkim/youcantspoilababy.org.pem");
  512. #dkim_key("host3.youcantspoilababy.org", "dkim", "/var/lib/dkim/youcantspoilababy.org.pem");
  513.  
  514. # Add new dkim_key for other domain.
  515. #dkim_key('Your_New_Domain_Name', 'dkim', 'Your_New_Pem_File');
  516.  
  517. @dkim_signature_options_bysender_maps = ( {
  518.     # ------------------------------------
  519.     # For domain: youcantspoilababy.org.
  520.     # ------------------------------------
  521.     # 'd' defaults to a domain of an author/sender address,
  522.     # 's' defaults to whatever selector is offered by a matching key
  523.  
  524.     #'[email protected]'    => { d => "youcantspoilababy.org", a => 'rsa-sha256', ttl =>  7*24*3600 },
  525.     #"[email protected]"    => { d => "youcantspoilababy.org", a => 'rsa-sha256', ttl =>  7*24*3600 },
  526.  
  527.     # explicit 'd' forces a third-party signature on foreign (hosted) domains
  528.     "youcantspoilababy.org"  => { d => "youcantspoilababy.org", a => 'rsa-sha256', ttl => 10*24*3600 },
  529.     #"host1.youcantspoilababy.org"  => { d => "host1.youcantspoilababy.org", a => 'rsa-sha256', ttl => 10*24*3600 },
  530.     #"host2.youcantspoilababy.org"  => { d => "host2.youcantspoilababy.org", a => 'rsa-sha256', ttl => 10*24*3600 },
  531.     # ---- End domain: youcantspoilababy.org ----
  532.  
  533.     # catchall defaults
  534.     '.' => { a => 'rsa-sha256', c => 'relaxed/simple', ttl => 30*24*3600 },
  535. } );
  536. # ------------ Disclaimer Setting ---------------
  537. # Uncomment this line to enable singing disclaimer in outgoing mails.
  538. #$defang_maps_by_ccat{+CC_CATCHALL} = [ 'disclaimer' ];
  539.  
  540. # Program used to signing disclaimer in outgoing mails.
  541. $altermime = '/usr/bin/altermime';
  542.  
  543. # Disclaimer in plain text formart.
  544. @altermime_args_disclaimer = qw(--disclaimer=/etc/postfix/disclaimer/_OPTION_.txt --disclaimer-html=/etc/postfix/disclaimer/_OPTION_.txt --force-for-bad-html);
  545.  
  546. @disclaimer_options_bysender_maps = ({
  547.     # Per-domain disclaimer setting: /etc/postfix/disclaimer/host1.iredmail.org.txt
  548.     #'host1.iredmail.org' => 'host1.iredmail.org',
  549.  
  550.     # Sub-domain disclaimer setting: /etc/postfix/disclaimer/iredmail.org.txt
  551.     #'.iredmail.org'      => 'iredmail.org',
  552.  
  553.     # Per-user disclaimer setting: /etc/postfix/disclaimer/boss.iredmail.org.txt
  554.     #'[email protected]'  => 'boss.iredmail.org',
  555.  
  556.     # Catch-all disclaimer setting: /etc/postfix/disclaimer/default.txt
  557.     '.' => 'default',
  558. },);
  559. # ------------ End Disclaimer Setting ---------------
  560. # Reporting and quarantining.
  561. @storage_sql_dsn = (
  562.     ['DBI:mysql:database=amavisd;host=127.0.0.1;port=3306', 'amavisd', 'JWzhJJfBmdji4FtXWYwgjzeu7awVB2'],
  563. );
  564.  
  565. # Lookup for per-recipient, per-domain and global policy.
  566. @lookup_sql_dsn = @storage_sql_dsn;
  567. # Don't send email with subject "UNCHECKED contents in mail FROM xxx".
  568. delete $admin_maps_by_ccat{&CC_UNCHECKED};
  569.  
  570. # Do not notify administrator about SPAM/VIRUS from remote servers.
  571. $virus_admin = undef;
  572. $spam_admin = undef;
  573. $banned_admin = undef;
  574. $bad_header_admin = undef;
  575.  
  576. # Num of pre-forked children.
  577. # WARNING: it must match (equal to or larger than) the number set in
  578. # /etc/postfix/master.cf "maxproc" column for the 'smtp-amavis' service.
  579. $max_servers = 4;
  580.  
  581. $localhost_name = $myhostname;
  582. # Amavisd on some Linux/BSD distribution use $banned_namepath_re instead of
  583. # $banned_filename_re, so we define some blocked file types here.
  584. #
  585. # Sample input for $banned_namepath_re:
  586. #
  587. #   P=p003\tL=1\tM=multipart/mixed\nP=p002\tL=1/2\tM=application/octet-stream\tT=dat\tN=my_docum.zip
  588. #
  589. # What it means:
  590. #   - T: type. e.g. zip archive.
  591. #   - M: MIME type. e.g. application/octet-stream.
  592. #   - N: suggested (MIME) name. e.g. my_docum.zip.
  593.  
  594. $banned_namepath_re = new_RE(
  595.     # Unknown binary files.
  596.     [qr'M=application/(zip|rar|arc|arj|zoo|gz|bz2)(,|\t).*T=dat(,|\t)'xmi => 'DISCARD'],
  597.  
  598.     [qr'T=(exe|exe-ms|lha|cab|dll)(,|\t)'xmi => 'DISCARD'],       # banned file(1) types
  599.     [qr'T=(pif|scr)(,|\t)'xmi => 'DISCARD'],                      # banned extensions - rudimentary
  600.     [qr'T=ani(,|\t)'xmi => 'DISCARD'],                            # banned animated cursor file(1) type
  601.     [qr'T=(mim|b64|bhx|hqx|xxe|uu|uue)(,|\t)'xmi => 'DISCARD'],   # banned extension - WinZip vulnerab.
  602.     [qr'M=application/x-msdownload(,|\t)'xmi => 'DISCARD'],       # block these MIME types
  603.     [qr'M=application/x-msdos-program(,|\t)'xmi => 'DISCARD'],
  604.     [qr'M=application/hta(,|\t)'xmi => 'DISCARD'],
  605.     [qr'M=(application/x-msmetafile|image/x-wmf)(,|\t)'xmi => 'DISCARD'],  # Windows Metafile MIME type
  606. );
  607. # Listen on specified addresses.
  608. #$inet_socket_bind = [ '127.0.0.1', '[::1]' ];
  609.  
  610.  
  611. # Custom Amavisd log template to always log SpamAssassin testing results,
  612. # useful for troubleshooting. if you want more verbose log, replace it by:
  613. #
  614. #   $log_templ = $log_verbose_templ;
  615. #
  616. # WARNING: $log_verbose_templ will log mail subject, this may be illegal
  617. #          according to the laws in some countries.
  618. #
  619. # Note: You can find the original log template at the bottom of
  620. #       /usr/sbin/amavisd-new.
  621. $log_templ = '
  622. [?%#D|#|Passed #
  623. [? [:ccat|major] |#
  624. OTHER|CLEAN|MTA-BLOCKED|OVERSIZED|BAD-HEADER-[:ccat|minor]|SPAMMY|SPAM|\
  625. UNCHECKED[?[:ccat|minor]||-ENCRYPTED|]|BANNED (%F)|INFECTED (%V)]#
  626. {[:actions_performed]}#
  627. ,[?%p|| %p][?%a||[?%l|| LOCAL] [:client_addr_port]][?%e|| \[%e\]] %s -> [%D|,]#
  628. [? %q ||, quarantine: %q]#
  629. [? %Q ||, Queue-ID: %Q]#
  630. [? %m ||, Message-ID: [:mail_addr_decode_octets|%m]]#
  631. [? %r ||, Resent-Message-ID: [:mail_addr_decode_octets|%r]]#
  632. [? %i ||, mail_id: %i]#
  633. , Hits: [:SCORE]#
  634. , size: %z#
  635. [? [:partition_tag] ||, pt: [:partition_tag]]#
  636. [~[:remote_mta_smtp_response]|["^$"]||[", queued_as: "]]\
  637. [remote_mta_smtp_response|[~%x|["queued as ([0-9A-Za-z]+)$"]|["%1"]|["%0"]]|/]#
  638. #, Subject: [:dquote|[:mime2utf8|[:header_field_octets|Subject]|100|1]]#
  639. #, From: [:uquote|[:mail_addr_decode_octets|[:rfc2822_from]]]#
  640. [? [:dkim|sig_sd]    ||, dkim_sd=[:dkim|sig_sd]]#
  641. [? [:dkim|newsig_sd] ||, dkim_new=[:dkim|newsig_sd]]#
  642. , %y ms#
  643. [? %#T ||, Tests: \[[%T|,]\]]#
  644. ]
  645. [?%#O|#|Blocked #
  646. [? [:ccat|major|blocking] |#
  647. OTHER|CLEAN|MTA-BLOCKED|OVERSIZED|BAD-HEADER-[:ccat|minor]|SPAMMY|SPAM|\
  648. UNCHECKED[?[:ccat|minor]||-ENCRYPTED|]|BANNED (%F)|INFECTED (%V)]#
  649. {[:actions_performed]}#
  650. ,[?%p|| %p][?%a||[?%l|| LOCAL] [:client_addr_port]][?%e|| \[%e\]] %s -> [%D|,]#
  651. [? %q ||, quarantine: %q]#
  652. [? %Q ||, Queue-ID: %Q]#
  653. [? %m ||, Message-ID: [:mail_addr_decode_octets|%m]]#
  654. [? %r ||, Resent-Message-ID: [:mail_addr_decode_octets|%r]]#
  655. [? %i ||, mail_id: %i]#
  656. , Hits: [:SCORE]#
  657. , size: %z#
  658. [? [:partition_tag] ||, pt: [:partition_tag]]#
  659. #, Subject: [:dquote|[:mime2utf8|[:header_field_octets|Subject]|100|1]]#
  660. #, From: [:uquote|[:mail_addr_decode_octets|[:rfc2822_from]]]#
  661. [? [:dkim|sig_sd]    ||, dkim_sd=[:dkim|sig_sd]]#
  662. [? [:dkim|newsig_sd] ||, dkim_new=[:dkim|newsig_sd]]#
  663. , %y ms#
  664. [? %#T ||, Tests: \[[%T|,]\]]#
  665. ]';
  666.  
  667.  
  668. 1;  # insure a defined return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement