AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 126282
Accepted
Glen Solsberry
Glen Solsberry
Asked: 2010-03-26 07:47:54 +0800 CST2010-03-26 07:47:54 +0800 CST 2010-03-26 07:47:54 +0800 CST

Postfix 检查外发邮件是否有垃圾邮件

  • 772

如何强制 postfix 检查(并记录/标记/等)所有外发邮件中的垃圾邮件?

只是想确保我在我的服务器上尽我所能。

编辑:后缀配置,按要求。

主文件

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes

smtpd_recipient_restrictions =
   permit_sasl_authenticated,
   permit_mynetworks,
   reject_unauth_destination

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

alias_maps = hash:/etc/aliases

myhostname = example.com
myorigin = /etc/mailname
mydestination = localhost, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
content_filter = smtp-amavis:[127.0.0.1]:10024

transport_maps = mysql:/etc/postfix/mysql/transport_maps.cf

virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_alias_domains.cf
virtual_alias_maps = mysql:/etc/postfix/mysql/virtual_alias_maps.cf


virtual_mailbox_base = /var/mail
virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf
virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
dovecot_destination_recipient_limit = 1

大师.cf

#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd
submission inet n       -       -       -       -       smtpd
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#smtps     inet  n       -       -       -       -       smtpd
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#628      inet  n       -       -       -       -       qmqpd
pickup    fifo  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
#qmgr     fifo  n       -       -       300     1       oqmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       -       -       -       smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay     unix  -       -       -       -       -       smtp
    -o smtp_fallback_relay=
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache

127.0.0.1:10025     inet    n   -   y   -   -   smtpd
    -o content_filter=
    -o local_recipient_maps=
    -o relay_recipient_maps=
    -o smtpd_restriction_classes=
    -o smtpd_helo_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_recipient_restrictions=permit_mynetworks,reject

    -o mynetworks=127.0.0.0/8
    -o strict_rfc821_envelopes=yes
    -o smtpd_error_sleep_time=0
    -o smtpd_soft_error_limit=1001
    -o smtpd_hard_error_limit=100

smtp-amavis unix -  -   y   -   2   smtp
    -o smtp_data_done_timeout=1200
    -o disable_dns_lookups=yes
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -   n   n   -   2   pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}

mysql/transport_maps.cf

user = user
password = password
hosts = 127.0.0.1

dbname = postfix

query = SELECT target FROM transports WHERE hostname = '%d' AND active = 1

mysql/virtual_alias_domains.cf

user = user
password = password
hosts = 127.0.0.1

dbname = postfix
select_field = domain
table = domains
where_field = domain
additional_conditions = AND active = 1

mysql/virtual_alias_maps.cf

user = user
password = password
hosts = 127.0.0.1

dbname = postfix
select_field = forward
table = aliases
where_field = source
additional_conditions = AND active = 1

mysql/virtual_mailbox_maps.cf

user = user
password = password
hosts = 127.0.0.1

dbname = postfix

query = SELECT mailbox_path FROM users WHERE address = '%s' AND active = 1
spam postfix
  • 4 4 个回答
  • 26672 Views

4 个回答

  • Voted
  1. Best Answer
    rkthkr
    2010-04-08T23:04:25+08:002010-04-08T23:04:25+08:00

    下面是一个用于检查传出消息的配置“存根”。

    在 main.cf 中:

    smtpd_sender_restrictions = 
       check_client_access cidr:/etc/postfix/internal_clients_filter
    

    并且:/etc/postfix/internal_clients_filter

    192.168.0.0/24 FILTER smtp:[127.0.0.1]:12501
    10.0.0.0/24 FILTER smtp:[127.0.0.1]:12501
    

    (您也可以通过其他方式为登录用户、IP、来自等执行此操作。)

    在 Amavisd-new 中使用政策银行:

    $interface_policy{'12501'} = 'INTERNAL'; 
    $policy_bank{'INTERNAL'} = {  # mail originating from clients in cidr:/etc/postfix/internal_clients_filter
      bypass_spam_checks_maps   => [0],  # spam-check outgoing mail 
      bypass_banned_checks_maps => [0],  # banned-check outgoing mail 
      bypass_header_checks_maps => [0],  # header-check outgoing mail  
      forward_method => 'smtp:[127.0.0.1]:12502', # relay to Postfix listener on port 12502
    };
    

    以及后缀中的重新注入路径:

    127.0.0.1:12502 inet    n    -    n    -    -    smtpd
        -o smtpd_recipient_restrictions=permit_mynetworks,reject
        -o smtpd_restriction_classes=
        -o smtpd_delay_reject=no
        -o smtpd_client_restrictions=
        -o smtpd_helo_restrictions=
        -o smtpd_sender_restrictions=
        -o mynetworks=127.0.0.0/8
        -o smtpd_data_restrictions
        -o smtpd_end_of_data_restrictions=
        -o local_header_rewrite_clients=
        -o smtpd_error_sleep_time=0
        -o smtpd_soft_error_limit=1001
        -o smtpd_hard_error_limit=1000
        -o smtpd_client_connection_count_limit=0
        -o smtpd_client_connection_rate_limit=0
        -o smtpd_milters=
        -o local_recipient_maps=
        -o relay_recipient_maps=
        -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_address_mappings
    
    • 8
  2. starfry
    2016-09-24T06:03:57+08:002016-09-24T06:03:57+08:00

    这是一个老问题,但我想我会分享一些允许使用出站 Procmail 过滤器的配置。首先,在master.cf:

    submission inet n       -       n       -       -       smtpd
      -o syslog_name=postfix/submission
      -o smtpd_tls_security_level=may
      -o smtpd_sasl_auth_enable=yes
      -o broken_sasl_auth_clients=yes
      -o smtpd_client_restrictions=permit_mynetworks,permit_sasl_authenticated,reject
      -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
      -o content_filter=procmail-outbound
    
    procmail-outbound unix  -       n       n       -       -       pipe
      flags=Rq user=mail argv=/usr/bin/procmail -t -m SENDER=${sender} RECIPIENT=${recipient} /etc/procmail/outbound.rc
    

    然后你可以在重新outbound.rc注入处理过的消息之前运行你需要的任何 procmail 配方,sendmail就像下面的示例配方一样:

    # Send mail
    :0 w
    | /usr/bin/sendmail -G -i -f $SENDER $RECIPIENT
    

    (请注意,该示例在提交服务(端口 587)上接受邮件,而不是smtp用于中继和投递的服务。)

    • 2
  3. dunxd
    2010-04-08T14:29:52+08:002010-04-08T14:29:52+08:00

    您的客户使用 smtp 服务器发送邮件——大概就是这个 postfix 服务器。

    外发邮件通过 Postfix 的 smtp 传输,上面的配置通过 amavisd 通过 content_filter 传递 - 所以我认为您的外发邮件已经得到处理。

    我建议您测试以使自己满意是否是这种情况。

    如果服务器不是很忙,您可以跟踪您的邮件日志,并观察当您发送包含GTUBE字符串 ( XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X) 的测试消息时会发生什么。Amavisd/spamassassin 应该会收到消息。如果是这样,那么您知道您的邮件在发送时正在被扫描。

    • 1
  4. Tobias Ernst
    2020-04-12T14:42:03+08:002020-04-12T14:42:03+08:00

    如果您在 main.cf 中定义 content_filter,则过滤器将应用于任何入站和出站接口(smtp、smtps、提交)。

    content_filter=clamav:{{ HOST_ALIAS_CLAMAV }}:{{ CLAMAV_SERVER_PORT }}
    

    确保您-o content_filter=在 clamav 进程部分设置为不会出现无限循环。

    0.0.0.0:{{ CLAMAV_FORWARD_PORT }} inet  n -       n       -       16      smtpd
        -o content_filter=
        ...
    
    • 0

相关问题

  • 代表客户发送电子邮件

  • 让 Postfix 以两种方式处理垃圾邮件

  • Linux sendmail 垃圾邮件?

  • 选择什么安全套件?

  • Exchange 2007:将带有 SenderID 的邮件移动到垃圾邮件文件夹失败?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve