我使用这个创建了一个邮件服务器
它确实有效,但我收到了大量的电子邮件,使用适当的 spamassassin 我收到了带有前缀主题的电子邮件,例如
***** SPAM ***** 2.9 ***** Do not miss,the fullyQtum Main Network Launches September 13th, 2017
但我不知道如何使用 Sieve 将垃圾邮件移至垃圾邮件文件夹。
这是我的鸽舍配置:
auth_mechanisms = plain login
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 {
auto = subscribe
special_use = \Drafts
}
mailbox Junk {
auto = subscribe
special_use = \Junk
}
mailbox Sent {
auto = subscribe
special_use = \Sent
}
mailbox Trash {
auto = subscribe
special_use = \Trash
}
prefix =
}
passdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
plugin {
sieve = /etc/dovecot/sieve.conf
}
protocols = imap lmtp pop3
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 = 0666
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_ca = </etc/ssl/acme/patrikx3.com/ca.cer
ssl_cert = </etc/ssl/acme/patrikx3.com/fullchain.cer
ssl_key = # hidden, use -P to show it
userdb {
args = uid=vmail gid=vmail home=/var/mail/vhosts/%d/%n
driver = static
}
protocol lmtp {
auth_socket_path = /var/run/dovecot/auth-master
mail_plugins = " sieve"
}
答案1
解决方法如下(耗时 7 个月):
apt install dovecot-sieve dovecot-managesieved
nano /etc/dovecot/conf.d/90-plugin.conf
添加或设置:
protocol lmtp {
mail_plugins = $mail_plugins sieve
auth_socket_path = /var/run/dovecot/auth-master
}
nano /etc/dovecot/sieve.conf
加入:
require ["fileinto", "mailbox"];
if header :contains "X-Spam-Flag" "YES" {
# move mail into Folder Spam, create folder if not exists
fileinto :create "Spam";
stop;
}
执行:
sievec /etc/dovecot/sieve.conf
nano /etc/spamassassin/local.cf
添加或设置它,就像这样(我认为你不需要其他一切):
report_safe 0
required_score 2.0
use_bayes 1
use_bayes_rules 1
bayes_auto_learn 1
skip_rbl_checks 0
use_razor2 1
use_pyzor 0
add_header all Status _YESNO_, score=_SCORE_ required=_REQD_ version=_VERSION_
bayes_ignore_header X-Bogosity
bayes_ignore_header X-Spam-Flag
bayes_ignore_header X-Spam-Status
再次编辑新文件:
nano /etc/dovecot/conf.d/90-sieve.conf
设置此配置,您不需要任何其他东西:
plugin {
sieve = /etc/dovecot/sieve.conf
}
编辑邮箱,因此 jo 有垃圾邮件,我认为 jo 只需要添加或取消注释垃圾邮件设置:
nano /etc/dovecot/conf.d/15-mailboxes.conf
添加此配置:
namespace inbox {
mailbox Drafts {
auto = subscribe
special_use = \Drafts
}
mailbox Junk {
auto = subscribe
special_use = \Junk
}
mailbox Trash {
auto = subscribe
special_use = \Trash
}
mailbox Sent {
auto = subscribe
special_use = \Sent
}
}
我的电子邮件服务器的用户是vmail
,因此请这样做:
chmod ug+w /etc/dovecot chmod ug+w /etc/dovecot/sieve.conf.svbin
chown -R vmail:vmail /etc/dovecot
重新启动邮件服务器:
service postfix reload && service spamassassin restart && service dovecot restart