设置 clamsmtp
简介
ClamSMTP 是一个简单的、轻量级的内容过滤器,用 C 语言编写,它接受 SMTP 连接,并可以使用 Clamav 检查病毒和垃圾邮件。电子邮件的 'DATA' 部分在电子邮件提交到队列以进行传递之前进行扫描。
设置 ClamSMTP
安装 ClamSMTP
apk add clamsmtp
按如下方式配置 clamsmtpd.conf 文件
OutAddress: 127.0.0.1:10026 Listen: 127.0.0.1:10025 ClamAddress: /var/run/clamav/clamd.sock TempDirectory: /tmp Action: drop Quarantine: on User: clamav ## The following line makes it possible to filter an entire network's SMTP traffic. ## If used, remove the OutAddress line above #TransparentProxy: on ## Uncomment if you wish to use a virus action script to perform further actions on the suspect email #VirusAction: /etc/postfix/scripts/virus_action.sh
以上配置支持将邮件发送到由管理员监控的邮箱的电子邮件地址。请记住将进入此邮箱的任何邮件都视为恶意的,因为它们可能包含病毒。此外,还有通知消息
一个非常好的病毒处理脚本可以在这里找到:virus_action.sh
配置 Postfix
将以下行添加到您的 postfix main.cf 文件中
content_filter = scan:[127.0.0.1]:10025
将以下行添加到您的 master.cf 文件的末尾
# AV scan filter (used by content_filter) scan unix - - n - 16 smtp -o smtp_send_xforward_command=yes -o smtp_enforce_tls=no # For injecting mail back into postfix from the filter 127.0.0.1:10026 inet n - n - 16 smtpd -o content_filter= -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks -o smtpd_helo_restrictions= -o smtpd_client_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks_style=host -o smtpd_authorized_xforward_hosts=127.0.0.0/8
启动服务并保存更改
重启 postfix 并启动 clamsmtp 服务
rc-service postfix restart rc-service clamsmtp start
最后,计划 clamsmtp 在启动时自动启动
rc-update add clamsmtpd
保存更改:lbu ci