use strict;
#
# Place your configuration directives here. They will override those in
# earlier files.
#
# See /usr/share/doc/amavisd-new/ for documentation and examples of
# the directives you can use in this file
#
#------------ Do not modify anything below this line -------------
#{1}
chomp($mydomain = "m1.mymxhost.com");
@local_domains_maps = 1;
@mynetworks = qw( 127.0.0.0/8 [::1] );
# listen on multiple TCP ports. 9998 is used for releasing quarantined mails.
$inet_socket_port = [10024, 10026, 9998];
# Enable virus check.
@bypass_virus_checks_maps = (
\%bypass_virus_checks,
\@bypass_virus_checks_acl,
$bypass_virus_checks_re,
);
# Enable spam check.
@bypass_spam_checks_maps = (
\%bypass_spam_checks,
\@bypass_spam_checks_acl,
$bypass_spam_checks_re,
);
$mailfrom_notify_admin = "root\@$mydomain";
$mailfrom_notify_recip = "root\@$mydomain";
$mailfrom_notify_spamadmin = "root\@$mydomain";
# Mail notify.
$mailfrom_notify_admin = "root\@$mydomain"; # notifications sender
$mailfrom_notify_recip = "root\@$mydomain"; # notifications sender
$mailfrom_notify_spamadmin = "root\@$mydomain"; # notifications sender
$mailfrom_to_quarantine = ''; # null return path; uses original sender if undef
# Disable defang banned mail.
$defang_banned = 0; # MIME-wrap passed mail containing banned name
$policy_bank{'MYNETS'} = { # mail originating from @mynetworks
originating => 1, # is true in MYNETS by default, but let's make it explicit
os_fingerprint_method => undef, # don't query p0f for internal clients
allow_disclaimers => 1, # enables disclaimer insertion if available
enable_dkim_signing => 1,
};
# it is up to MTA to re-route mail from authenticated roaming users or
# from internal hosts to a dedicated TCP port (such as 10026) for filtering
$interface_policy{'10026'} = 'ORIGINATING';
$policy_bank{'ORIGINATING'} = { # mail supposedly originating from our users
#inet_acl => [qw(127.0.0.1 [::1])], # ORIGINATING: restrict access to these IP addresses
originating => 1, # declare that mail was submitted by our smtp client
allow_disclaimers => 1, # enables disclaimer insertion if available
enable_dkim_signing => 1,
# notify administrator of locally originating malware
virus_admin_maps => ["root\@$mydomain"],
spam_admin_maps => [],
bad_header_admin_maps => [],
banned_admin_maps => ["root\@$mydomain"],
warnbadhsender => 1,
warnbannedsender => 1,
# force MTA conversion to 7-bit (e.g. before DKIM signing)
#smtpd_discard_ehlo_keywords => ['8BITMIME'],
# don't remove NOTIFY=SUCCESS option
terminate_dsn_on_notify_success => 0,
# don't perform spam/virus/header check.
bypass_spam_checks_maps => [1], # ORIGINATING spam
bypass_header_checks_maps => [1], # ORIGINATING bad-header
bypass_virus_checks_maps => [1], # ORIGINATING virus
bypass_banned_checks_maps => [1], # ORIGINATING banned file types
};
# Custom Amavisd log template to always log SpamAssassin testing results,
# useful for troubleshooting. if you want more verbose log, replace it by:
#
# $log_templ = $log_verbose_templ;
#
# WARNING: $log_verbose_templ will log mail subject, this may be illegal
# according to the laws in some countries.
#
# Note: You can find the original log template at the bottom of
# /usr/sbin/amavisd-new.
$log_templ = '
[?%#D|#|Passed #
[? [:ccat|major] |#
OTHER|CLEAN|MTA-BLOCKED|OVERSIZED|BAD-HEADER-[:ccat|minor]|SPAMMY|SPAM|\
UNCHECKED[?[:ccat|minor]||-ENCRYPTED|]|BANNED (%F)|INFECTED (%V)]#
{[:actions_performed]}#
,[?%p|| %p][?%a||[?%l|| LOCAL] [:client_addr_port]][?%e|| \[%e\]] %s -> [%D|,]#
[? %q ||, quarantine: %q]#
[? %Q ||, Queue-ID: %Q]#
[? %m ||, Message-ID: [:mail_addr_decode_octets|%m]]#
[? %r ||, Resent-Message-ID: [:mail_addr_decode_octets|%r]]#
[? %i ||, mail_id: %i]#
, Hits: [:SCORE]#
, size: %z#
[? [:partition_tag] ||, pt: [:partition_tag]]#
[~[:remote_mta_smtp_response]|["^$"]||[", queued_as: "]]\
[remote_mta_smtp_response|[~%x|["queued as ([0-9A-Za-z]+)$"]|["%1"]|["%0"]]|/]#
#, Subject: [:dquote|[:mime2utf8|[:header_field_octets|Subject]|100|1]]#
#, From: [:uquote|[:mail_addr_decode_octets|[:rfc2822_from]]]#
[? [:dkim|sig_sd] ||, dkim_sd=[:dkim|sig_sd]]#
[? [:dkim|newsig_sd] ||, dkim_new=[:dkim|newsig_sd]]#
, %y ms#
[? %#T ||, Tests: \[[%T|,]\]]#
]
[?%#O|#|Blocked #
[? [:ccat|major|blocking] |#
OTHER|CLEAN|MTA-BLOCKED|OVERSIZED|BAD-HEADER-[:ccat|minor]|SPAMMY|SPAM|\
UNCHECKED[?[:ccat|minor]||-ENCRYPTED|]|BANNED (%F)|INFECTED (%V)]#
{[:actions_performed]}#
,[?%p|| %p][?%a||[?%l|| LOCAL] [:client_addr_port]][?%e|| \[%e\]] %s -> [%D|,]#
[? %q ||, quarantine: %q]#
[? %Q ||, Queue-ID: %Q]#
[? %m ||, Message-ID: [:mail_addr_decode_octets|%m]]#
[? %r ||, Resent-Message-ID: [:mail_addr_decode_octets|%r]]#
[? %i ||, mail_id: %i]#
, Hits: [:SCORE]#
, size: %z#
[? [:partition_tag] ||, pt: [:partition_tag]]#
#, Subject: [:dquote|[:mime2utf8|[:header_field_octets|Subject]|100|1]]#
#, From: [:uquote|[:mail_addr_decode_octets|[:rfc2822_from]]]#
[? [:dkim|sig_sd] ||, dkim_sd=[:dkim|sig_sd]]#
[? [:dkim|newsig_sd] ||, dkim_new=[:dkim|newsig_sd]]#
, %y ms#
[? %#T ||, Tests: \[[%T|,]\]]#
]';
# Set hostname.
$myhostname = "m1.mymxhost.com";
$mydomain = $myhostname;
$localhost_name = $myhostname;
# Set listen IP/PORT.
$notify_method = 'smtp:[127.0.0.1]:10025';
$forward_method = 'smtp:[127.0.0.1]:10025';
@av_scanners = (
#### http://www.clamav.net/
['ClamAV-clamd',
\&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd.ctl"],
qr/\bOK$/, qr/\bFOUND$/,
qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
);
@av_scanners_backup = (
### http://www.clamav.net/ - backs up clamd or Mail::ClamAV
['ClamAV-clamscan', 'clamscan',
"--stdout --disable-summary -r --tempdir=$TEMPBASE {}", [0], [1],
qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
);
#
# Port used to release quarantined mails.
#
$interface_policy{'9998'} = 'AM.PDP-INET';
$policy_bank{'AM.PDP-INET'} = {
protocol => 'AM.PDP', # select Amavis policy delegation protocol
#inet_acl => [qw(127.0.0.1 [::1])], # QUARANTINE: restrict access to these IP addresses
auth_required_release => 1, # 0 - don't require secret_id for amavisd-release
#log_level => 4,
#always_bcc_by_ccat => {CC_CLEAN, 'admin@example.com'},
};
#########################
# Default action applied to detected spam/virus/banned/bad-header, and how to
# quarantine them
#
# Available actions:
# - D_PASS: Mail will pass to recipients, regardless of bad contents.
# If a quarantine is configured, a copy of the mail will go there.
# Note that including a recipient in a @*_lovers_maps is
# functionally equivalent to setting '*_destiny = D_PASS;'
# for that recipient.
#
# - D_BOUNCE: Mail will not be delivered to its recipients. A non-delivery
# notification (bounce) will be created and sent to the sender.
#
# - D_REJECT: Mail will not be delivered to its recipients. Amavisd will
# send the typical 55x reject response to the upstream MTA and
# that MTA may create a reject notice (bounce) and return it to
# the sender.
# This notice is not as informative as the one created using
# D_BOUNCE, so usually D_BOUNCE is preferred over D_REJECT.
# If a quarantine is configured, a copy of the mail will go
# there, if not mail message will be lost, but the sender should
# be notified their message was rejected.
#
# - D_DISCARD: Mail will not be delivered to its recipients and the sender
# normally will NOT be notified.
# If a quarantine is configured, a copy of the mail will go
# there, if not mail message will be lost. Note that there are
# additional settings available that can send notifications to
# persons that normally may not be notified when an undesirable
# message is found, so it is possible to notify the sender even
# when using D_DISCARD.
#
# Where to store quarantined mail message:
#
# - 'local:spam-%i-%m', quarantine mail on local file system.
# - 'sql:', quarantine mail in SQL server specified in @storage_sql_dsn.
# - undef, do not quarantine mail.
# SPAM.
$final_spam_destiny = D_DISCARD;
$spam_quarantine_method = 'sql:';
$spam_quarantine_to = 'spam-quarantine';
# Virus
$final_virus_destiny = D_DISCARD;
$virus_quarantine_method = 'sql:';
$virus_quarantine_to = 'virus-quarantine';
# Banned
$final_banned_destiny = D_DISCARD;
$banned_files_quarantine_method = 'sql:';
$banned_quarantine_to = 'banned-quarantine';
# Bad header.
$final_bad_header_destiny = D_DISCARD;
$bad_header_quarantine_method = 'sql:';
$bad_header_quarantine_to = 'bad-header-quarantine';
#########################
# Quarantine CLEAN mails.
# Don't forget to enable clean quarantine in policy bank 'MYUSERS'.
#
#$clean_quarantine_method = 'sql:';
#$clean_quarantine_to = 'clean-quarantine';
$sql_allow_8bit_address = 1;
$timestamp_fmt_mysql = 1;
# a string to prepend to Subject (for local recipients only) if mail could
# not be decoded or checked entirely, e.g. due to password-protected archives
#$undecipherable_subject_tag = '***UNCHECKED*** '; # undef disables it
$undecipherable_subject_tag = undef;
# Hope to fix 'nested MAIL command' issue on high load server.
$smtp_connection_cache_enable = 0;
# The default set of header fields to be signed can be controlled
# by setting %signed_header_fields elements to true (to sign) or
# to false (not to sign). Keys must be in lowercase, e.g.:
# 0 -> off
# 1 -> on
$signed_header_fields{'received'} = 0;
$signed_header_fields{'to'} = 1;
# Add dkim_key here.
dkim_key("mymxhost.com", "dkim", "/var/lib/dkim/mymxhost.com.pem");
# Note that signing mail for subdomains with a key of a parent
# domain is treated by recipients as a third-party key, which
# may 'hold less merit' in their eyes. If one has a choice,
# it is better to publish a key for each domain (e.g. host1.a.cn)
# if mail is really coming from it. Sharing a pem file
# for multiple domains may be acceptable, so you don't need
# to generate a different key for each subdomain, but you
# do need to publish it in each subdomain. It is probably
# easier to avoid sending addresses like host1.a.cn and
# always use a parent domain (a.cn) in 'From:', thus
# avoiding the issue altogether.
#dkim_key("host1.mymxhost.com", "dkim", "/var/lib/dkim/mymxhost.com.pem");
#dkim_key("host3.mymxhost.com", "dkim", "/var/lib/dkim/mymxhost.com.pem");
# Add new dkim_key for other domain.
#dkim_key('Your_New_Domain_Name', 'dkim', 'Your_New_Pem_File');
@dkim_signature_options_bysender_maps = ( {
# ------------------------------------
# For domain: mymxhost.com.
# ------------------------------------
# 'd' defaults to a domain of an author/sender address,
# 's' defaults to whatever selector is offered by a matching key
#'postmaster@mymxhost.com' => { d => "mymxhost.com", a => 'rsa-sha256', ttl => 7*24*3600 },
#"spam-reporter@mymxhost.com" => { d => "mymxhost.com", a => 'rsa-sha256', ttl => 7*24*3600 },
# explicit 'd' forces a third-party signature on foreign (hosted) domains
"mymxhost.com" => { d => "mymxhost.com", a => 'rsa-sha256', ttl => 10*24*3600 },
#"host1.mymxhost.com" => { d => "host1.mymxhost.com", a => 'rsa-sha256', ttl => 10*24*3600 },
#"host2.mymxhost.com" => { d => "host2.mymxhost.com", a => 'rsa-sha256', ttl => 10*24*3600 },
# ---- End domain: mymxhost.com ----
# catchall defaults
'.' => { a => 'rsa-sha256', c => 'relaxed/simple', ttl => 30*24*3600 },
} );
# ------------ Disclaimer Setting ---------------
# Uncomment this line to enable singing disclaimer in outgoing mails.
#$defang_maps_by_ccat{+CC_CATCHALL} = [ 'disclaimer' ];
# Program used to signing disclaimer in outgoing mails.
$altermime = '/usr/bin/altermime';
# Disclaimer in plain text formart.
@altermime_args_disclaimer = qw(--disclaimer=/etc/postfix/disclaimer/_OPTION_.txt --disclaimer-html=/etc/postfix/disclaimer/_OPTION_.txt --force-for-bad-html);
@disclaimer_options_bysender_maps = ({
# Per-domain disclaimer setting: /etc/postfix/disclaimer/host1.iredmail.org.txt
#'host1.iredmail.org' => 'host1.iredmail.org',
# Sub-domain disclaimer setting: /etc/postfix/disclaimer/iredmail.org.txt
#'.iredmail.org' => 'iredmail.org',
# Per-user disclaimer setting: /etc/postfix/disclaimer/boss.iredmail.org.txt
#'boss@iredmail.org' => 'boss.iredmail.org',
# Catch-all disclaimer setting: /etc/postfix/disclaimer/default.txt
'.' => 'default',
},);
# ------------ End Disclaimer Setting ---------------
# Reporting and quarantining.
@storage_sql_dsn = (['DBI:mysql:database=XXXXXXX;host=127.0.0.1;port=XXXXX', ****REMOVED*****]);
# Lookup for per-recipient, per-domain and global policy.
@lookup_sql_dsn = @storage_sql_dsn;
# Don't send email with subject "UNCHECKED contents in mail FROM xxx".
delete $admin_maps_by_ccat{&CC_UNCHECKED};
# Do not notify administrator about SPAM/VIRUS from remote servers.
$virus_admin = undef;
$spam_admin = undef;
$banned_admin = undef;
$bad_header_admin = undef;
# Num of pre-forked children.
# WARNING: it must match (equal to or larger than) the number set in
# /etc/postfix/master.cf "maxproc" column for the 'smtp-amavis' service.
$max_servers = 1;
# Enable DKIM signing/verification
$enable_dkim_verification = 1;
#$enable_dkim_signing = 1; # we have dkim signing enabled in policy banks.
# Amavisd log level. Verbosity: 0, 1, 2, 3, 4, 5, -d.
$log_level = 0;
# SpamAssassin debugging (require $log_level). Default if off (0).
$sa_debug = 0;
# Amavisd on some Linux/BSD distribution use $banned_namepath_re instead of
# $banned_filename_re, so we define some blocked file types here.
#
# Sample input for $banned_namepath_re:
#
# P=p003\tL=1\tM=multipart/mixed\nP=p002\tL=1/2\tM=application/octet-stream\tT=dat\tN=my_docum.zip
# P=p003,L=1,M=multipart/mixed | P=p002,L=1/2,M=application/zip,T=zip,N=FedEx_00628727.zip | P=p005,L=1/2/2,T=asc,N=FedEx_00628727.doc.wsf
#
# What it means:
# - T: type. e.g. zip archive.
# - M: MIME type. e.g. application/octet-stream.
# - N: suggested (MIME) name. e.g. my_docum.zip.
$banned_namepath_re = new_RE(
#[qr'T=(rar|arc|arj|zoo|gz|bz2)(,|\t)'xmi => 'DISCARD'], # Compressed file types
[qr'T=x-(msdownload|msdos-program|msmetafile)(,|\t)'xmi => 'DISCARD'],
[qr'T=(hta)(,|\t)'xmi => 'DISCARD'],
# Dangerous mime types
[qr'T=(9|386|LeChiffre|aaa|abc|aepl|ani|aru|atm|aut|b64|bat|bhx|bin|bkd|blf|bll|bmw|boo|bps|bqf|breaking_bad|buk|bup|bxz|cc|ccc|ce0|ceo|cfxxe|chm|cih|cla|class|cmd|com|cpl|crinf|crjoker|crypt|cryptolocker|cryptowall|ctbl|cxq|cyw|dbd|delf|dev|dlb|dli|dll|dllx|dom|drv|dx|dxz|dyv|dyz|ecc|exe|exe-ms|exe1|exe_renamed|exx|ezt|ezz|fag|fjl|fnr|fuj|good|gzquar|hlp|hlw|hqx|hsq|hts|iva|iws|jar|js|kcd|keybtc@inbox_com|let|lik|lkh|lnk|locky|lok|lol!|lpaq5|magic|mfu|micro|mim|mjg|mjz|nls|oar|ocx|osa|ozd|pcx|pgm|php2|php3|pid|pif|plc|pr|pzdc|qit|qrn|r5a|rhk|rna|rsc_tmp|s7p|scr|shs|ska|smm|smtmp|sop|spam|ssy|swf|sys|tko|tps|tsa|tti|ttt|txs|upa|uu|uue|uzy|vb|vba|vbe|vbs|vbx|vexe|vxd|vzr|wlpginstall|ws|wsc|wsf|wsh|wss|xdu|xir|xlm|xlv|xnt|xnxx|xtbl|xxe|xxx|xyz|zix|zvz|zzz)(,|\t)'xmi => 'DISCARD'],
# Dangerous file name extensions
[qr'N=.*\.(9|386|LeChiffre|aaa|abc|aepl|ani|aru|atm|aut|b64|bat|bhx|bin|bkd|blf|bll|bmw|boo|bps|bqf|breaking_bad|buk|bup|bxz|cc|ccc|ce0|ceo|cfxxe|chm|cih|cla|class|cmd|com|cpl|crinf|crjoker|crypt|cryptolocker|cryptowall|ctbl|cxq|cyw|dbd|delf|dev|dlb|dli|dll|dllx|dom|drv|dx|dxz|dyv|dyz|ecc|exe|exe-ms|exe1|exe_renamed|exx|ezt|ezz|fag|fjl|fnr|fuj|good|gzquar|hlp|hlw|hqx|hsq|hts|iva|iws|jar|js|kcd|keybtc@inbox_com|let|lik|lkh|lnk|locky|lok|lol!|lpaq5|magic|mfu|micro|mim|mjg|mjz|nls|oar|ocx|osa|ozd|pcx|pgm|php2|php3|pid|pif|plc|pr|pzdc|qit|qrn|r5a|rhk|rna|rsc_tmp|s7p|scr|shs|ska|smm|smtmp|sop|spam|ssy|swf|sys|tko|tps|tsa|tti|ttt|txs|upa|uu|uue|uzy|vb|vba|vbe|vbs|vbx|vexe|vxd|vzr|wlpginstall|ws|wsc|wsf|wsh|wss|xdu|xir|xlm|xlv|xnt|xnxx|xtbl|xxe|xxx|xyz|zix|zvz|zzz)$'xmi => 'DISCARD'],
);
# $bounce_killer_score defaults to 100, it will cause quota exceed notification
# email sent by Dovecot quarantined by Amavisd.
$penpals_bonus_score = undef;
$bounce_killer_score = 0;
# Selectively disable some of the header checks
#
# Duplicate or multiple occurrence of a header field
$allowed_header_tests{'multiple'} = 0;
# Missing some headers. e.g. 'Date:'
$allowed_header_tests{'missing'} = 0;
# Listen on specified addresses.
$inet_socket_bind = ['127.0.0.1'];
# Set ACL
@inet_acl = qw(127.0.0.1 [::1]);
1; # insure a defined return