我有一台可以工作的Dovecot服务器。我可以收到雷鸟和蓝光邮件客户端的邮件。我用smtp2go发送邮件。
我想配置鸽子孔筛,但发现配置是非常令人生畏的。
所有邮件都被传递到MySQL数据库中定义的虚拟邮箱。它们会转到/var/mail/vhost。我现在只托管一个域名。
那么,最简单的设置方法是什么呢?我现在要做的就是让垃圾邮件发送到每个用户的垃圾邮件文件夹中。dovecot -n的输出:
# 2.2.33.2 (d6601f4ec): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.21 (92477967)
# OS: Linux 4.15.0-47-generic x86_64 Ubuntu 18.04.2 LTS ext4
auth_mechanisms = plain login
log_path = /var/log/dovecot.log
mail_location = maildir:/var/mail/vhosts/%d/%n/
mail_privileged_group = mail
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext
namespace inbox {
inbox = yes
location =
mailbox Drafts {
special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Trash {
special_use = \Trash
}
prefix =
}
passdb {
args = /etc/dovecot/deny-users
deny = yes
driver = passwd-file
}
passdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
postmaster_address = dev@vietfeir.com
protocols = imap lmtp sieve
service auth-worker {
user = vmail
}
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0666
user = postfix
}
unix_listener auth-userdb {
mode = 0600
user = vmail
}
user = dovecot
}
service imap-login {
inet_listener imap {
port = 0
}
inet_listener imaps {
port = 993
ssl = yes
}
}
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
}
}
service pop3-login {
inet_listener pop3 {
port = 0
}
inet_listener pop3s {
port = 995
ssl = yes
}
}
ssl = required
ssl_cert = </etc/letsencrypt/live/civicrm.vietfeir.com/fullchain.pem
ssl_client_ca_dir = /etc/ssl/certs
ssl_key = # hidden, use -P to show it
userdb {
driver = passwd
}
userdb {
args = uid=vmail gid=vmail home=/var/mail/vhosts/%d/%n
driver = static
}下面是当前的dovecot -n输出:
# 2.2.33.2 (d6601f4ec): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.21 (92477967)
# OS: Linux 4.15.0-47-generic x86_64 Ubuntu 18.04.2 LTS ext4
auth_mechanisms = plain login
lda_mailbox_autocreate = yes
log_path = /var/log/dovecot.log
mail_location = maildir:/var/mail/vhosts/%d/%n/
mail_privileged_group = mail
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext
namespace inbox {
inbox = yes
location =
mailbox Drafts {
special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Spam {
auto = subscribe
special_use = \Junk
}
mailbox Trash {
special_use = \Trash
}
prefix =
}
passdb {
args = /etc/dovecot/deny-users
deny = yes
driver = passwd-file
}
passdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
plugin {
sieve_before = /var/mail/before.svbin
sieve_extensions = +fileinto
sieve_trace_dir = /var/log
sieve_trace_level = matching
}
postmaster_address = dev@vietfeir.com
protocols = imap lmtp
service auth-worker {
user = vmail
}
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0666
user = postfix
}
unix_listener auth-userdb {
mode = 0600
user = vmail
}
user = dovecot
}
service imap-login {
inet_listener imap {
port = 0
}
inet_listener imaps {
port = 993
ssl = yes
}
}
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
}
}
service pop3-login {
inet_listener pop3 {
port = 0
}
inet_listener pop3s {
port = 995
ssl = yes
}
}
ssl = required
ssl_cert = </etc/letsencrypt/live/civicrm.vietfeir.com/fullchain.pem
ssl_client_ca_dir = /etc/ssl/certs
ssl_key = # hidden, use -P to show it
userdb {
driver = passwd
}
userdb {
args = uid=vmail gid=vmail home=/var/mail/vhosts/%d/%n
driver = static
}注意:我尝试过使用before.sieve和before.svbin,但没有区别。
这是日志:
## Started executing script 'before'
2: header test
2: starting `:contains' match with `i;ascii-casemap' comparator:
2: extracting `X-Spam-Level' headers from message
2: matching value `**************************************************'
2: with key `*****' => 1
2: finishing match with result: matched
2: jump if result is false
2: not jumping
3: fileinto action
3: store message in mailbox `Hormel'
4: stop command; end all script execution
## Finished executing script 'before'它表示邮件存储在邮箱“Hormel”中,但没有创建邮箱。
发布于 2019-04-13 20:31:13
在您当前的配置中,我没有看到会阻止您简单地在任何用户配置的文件前面添加另一个筛网文件的任何内容:
protocol lmtp {
mail_plugins = $mail_plugins sieve
}
plugin {
sieve_before = /var/mail/before.sieve
sieve_extensions = +fileinto +mailbox
}这为您提供了一个/var/mail/before.sieve文件,该文件将在任何其他筛子脚本之前执行。您可以根据您知道的垃圾邮件过滤为您添加的某个标头来移动邮件:
require ["fileinto", "mailbox"];
if header :contains "X-Spam-Level" "*****" {
fileinto :create "Junk";
stop;
}只要您使用sievec /var/mail/before.sieve手动编译该文件(创建/var/mail/before.svbin),该文件就不需要被写入。
在您实现这样的东西之前,请检查这对所有用户是否真的有用--也许他们想以不同的方式过滤他们的邮件,那么sieve_default可能更合适。
https://serverfault.com/questions/962890
复制相似问题