Configure maildrop mailfilters
This commit is contained in:
@@ -9,6 +9,11 @@
|
|||||||
when: item not in uberspace_mail_domain_result.stdout_lines
|
when: item not in uberspace_mail_domain_result.stdout_lines
|
||||||
loop: "{{ mail_domains.get(ansible_facts.user_id, []) }}"
|
loop: "{{ mail_domains.get(ansible_facts.user_id, []) }}"
|
||||||
|
|
||||||
|
- name: Set up .qmail file
|
||||||
|
copy:
|
||||||
|
content: "{{ ansible_facts.user_id }}-lukas"
|
||||||
|
dest: "{{ ansible_facts.env.HOME }}/.qmail"
|
||||||
|
|
||||||
- name: Delete system Maildir
|
- name: Delete system Maildir
|
||||||
file:
|
file:
|
||||||
path: "{{ ansible_facts.env.HOME }}/Maildir"
|
path: "{{ ansible_facts.env.HOME }}/Maildir"
|
||||||
@@ -27,6 +32,22 @@
|
|||||||
vars:
|
vars:
|
||||||
user: lukas
|
user: lukas
|
||||||
|
|
||||||
|
- name: Create mailfilter config
|
||||||
|
template:
|
||||||
|
src: mailfilters/{{ ansible_facts.user_id }}.j2
|
||||||
|
dest: "{{ ansible_facts.env.HOME }}/.config/mailfilter"
|
||||||
|
mode: 0600
|
||||||
|
|
||||||
|
- name: Use custom mailfilter in .qmail-default
|
||||||
|
copy:
|
||||||
|
content: "|maildrop /home/{{ ansible_facts.user_id }}/.config/mailfilter"
|
||||||
|
dest: "{{ ansible_facts.env.HOME }}/.qmail-default"
|
||||||
|
|
||||||
|
- name: Delete Uberspace .spamfolder config
|
||||||
|
file:
|
||||||
|
path: "{{ ansible_facts.env.HOME }}/.spamfolder"
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Create qdated key
|
- name: Create qdated key
|
||||||
command:
|
command:
|
||||||
cmd: qdated-makekey
|
cmd: qdated-makekey
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
# check if we're called from a .qmail-EXT instead of .qmail
|
||||||
|
import EXT
|
||||||
|
if ( $EXT )
|
||||||
|
{
|
||||||
|
# does a vmailmgr user named $EXT exist?
|
||||||
|
# if yes, deliver mail to their Maildir instead
|
||||||
|
VUSER_DIRECTORY = `dumpvuser $EXT | grep '^Directory' | awk '{ print $2 }'`
|
||||||
|
if ( $VUSER_DIRECTORY )
|
||||||
|
{
|
||||||
|
MAILDIR="$HOME/$VUSER_DIRECTORY"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# no VUSER_DIRECTORY found, so let's check for a catchall
|
||||||
|
CATCHALL_TARGET = `dumpvuser + | grep '^Forward: ' | awk '{ print $2 }'`
|
||||||
|
if ( $CATCHALL_TARGET )
|
||||||
|
{
|
||||||
|
# there is a catchall mailbox, retrieve its directory
|
||||||
|
VUSER_DIRECTORY = `dumpvuser $CATCHALL_TARGET | grep '^Directory' | awk '{ print $2 }'`
|
||||||
|
if ( $VUSER_DIRECTORY )
|
||||||
|
{
|
||||||
|
MAILDIR="$HOME/$VUSER_DIRECTORY"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# check if the spam score is higher than our threshold
|
||||||
|
if ( /^X-Rspamd-Bar: \+{$MOVESCORE,}$/ )
|
||||||
|
{
|
||||||
|
# yes, move to Spam folder and exit
|
||||||
|
|
||||||
|
SPAMFOLDER="$MAILDIR/.Spam"
|
||||||
|
|
||||||
|
# make sure the spam folder actually exists
|
||||||
|
`test -d "$SPAMFOLDER"; or maildirmake "$SPAMFOLDER"`
|
||||||
|
|
||||||
|
to "$SPAMFOLDER"
|
||||||
|
# 'to' implies 'exit'
|
||||||
|
}
|
||||||
|
|
||||||
|
# forward to addresses from vmailmgr config
|
||||||
|
VUSER_FORWARD = `dumpvuser $EXT | grep '^Forward: ' | awk '{ print $2 }' | tr '\n' ' '`
|
||||||
|
if ( $VUSER_FORWARD )
|
||||||
|
{
|
||||||
|
cc "!$VUSER_FORWARD"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ensure that the vmailmgr user has mailbox delivery enabled
|
||||||
|
VUSER_HAS_MAILBOX = `dumpvuser $EXT | grep '^Has-Mailbox: ' | awk '{ print $2 }'`
|
||||||
|
VUSER_MAILBOX_ENABLED = `dumpvuser $EXT | grep '^Mailbox-Enabled: ' | awk '{ print $2 }'`
|
||||||
|
if ( "$VUSER_HAS_MAILBOX" eq "false" || "$VUSER_MAILBOX_ENABLED" eq "false" )
|
||||||
|
{
|
||||||
|
log "Local mailbox delivery explicitly disabled for this address"
|
||||||
|
EXITCODE=100 # hard error
|
||||||
|
exit
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# config
|
||||||
|
MOVESCORE=5 # minimum spam score to move the email to the Spam folder
|
||||||
|
MAILDIR="$HOME/users/lukas" # default Maildir
|
||||||
|
|
||||||
|
{% include '_common.j2' %}
|
||||||
|
|
||||||
|
to "$MAILDIR"
|
||||||
|
# 'to' implies 'exit'
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# config
|
||||||
|
MOVESCORE=5 # minimum spam score to move the email to the Spam folder
|
||||||
|
MAILDIR="$HOME/users/lukas" # default Maildir
|
||||||
|
|
||||||
|
{% include '_common.j2' %}
|
||||||
|
|
||||||
|
if ( $MAILDIR =~ /\/lukas$/ )
|
||||||
|
{
|
||||||
|
# deliver GitHub notifications to the Kirby folders
|
||||||
|
|
||||||
|
`test -d "$MAILDIR/.Kirby2"; or maildirmake "$MAILDIR/.Kirby2"`
|
||||||
|
`test -d "$MAILDIR/.Kirby3"; or maildirmake "$MAILDIR/.Kirby3"`
|
||||||
|
|
||||||
|
if( /^List-Archive: https:\/\/github.com\/getkirby-v2\// )
|
||||||
|
{
|
||||||
|
MAILDIR="$MAILDIR/.Kirby2"
|
||||||
|
}
|
||||||
|
|
||||||
|
if( /^List-Archive: https:\/\/github.com\/getkirby\// )
|
||||||
|
{
|
||||||
|
MAILDIR="$MAILDIR/.Kirby3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
to "$MAILDIR"
|
||||||
|
# 'to' implies 'exit'
|
||||||
Reference in New Issue
Block a user