wip
This commit is contained in:
@@ -231,7 +231,9 @@ let
|
||||
if string :is "''${userfor}" "shelvacu" {
|
||||
addheader "X-Vacu-Sieved" "''${sieved_message}";
|
||||
if ihave "imapsieve" {
|
||||
discard;
|
||||
if environment :matches "imap.user" "*" {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
if allof(
|
||||
${envelope_is "amznbsns@shelvacu.com"},
|
||||
@@ -273,7 +275,7 @@ let
|
||||
${concatStrings email_filters}
|
||||
${concatStrings domain_filters}
|
||||
else {
|
||||
fileinto "INBOX";
|
||||
keep;
|
||||
}
|
||||
}
|
||||
# disable any sieve scripts that might want to run after this one
|
||||
|
75
mailtest-notes.py
Normal file
75
mailtest-notes.py
Normal file
@@ -0,0 +1,75 @@
|
||||
import sys
|
||||
sys.argv.insert(1, "192.168.1.2")
|
||||
import smtplib
|
||||
import imaplib
|
||||
import imap_tools
|
||||
import time
|
||||
import ssl
|
||||
import argparse
|
||||
import uuid
|
||||
import requests
|
||||
from typing import NamedTuple
|
||||
|
||||
#--mailfrom whoeve2@example.com --rcptto sieve2est@shelvacu.com --username shelvacu --imap-move-to testFolder --imap-dir testFolder
|
||||
sys.argv.append("--mailfrom")
|
||||
sys.argv.append("whoev2@example.com")
|
||||
sys.argv.append("--rcptto")
|
||||
sys.argv.append("sieve2est@shelvacu.com")
|
||||
sys.argv.append("--username")
|
||||
sys.argv.append("shelvacu")
|
||||
sys.argv.append("--imap-move-to")
|
||||
sys.argv.append("testFolder")
|
||||
sys.argv.append("--imap-dir")
|
||||
sys.argv.append("testFolder")
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('host', type = str)
|
||||
parser.add_argument('--mailfrom', default = 'foo@example.com')
|
||||
parser.add_argument('--rcptto', default = 'awesome@vacu.store')
|
||||
parser.add_argument('--subject', default = 'Some test message')
|
||||
parser.add_argument('--header', action = 'append', default = [])
|
||||
parser.add_argument('--submission', default = False, action='store_true')
|
||||
parser.add_argument('--smtp-starttls', default = None, action='store_true')
|
||||
parser.add_argument('--imap-insecure', default = False, action = 'store_true')
|
||||
parser.add_argument('--imap-move-to')
|
||||
parser.add_argument('--imap-dir', default = None)
|
||||
parser.add_argument('--username')
|
||||
parser.add_argument('--password')
|
||||
parser.add_argument('--expect-refused',
|
||||
dest = 'expect',
|
||||
action = 'store_const',
|
||||
const = 'refused',
|
||||
default = 'received'
|
||||
)
|
||||
parser.add_argument('--expect-flag', action = 'append', default = [])
|
||||
parser.add_argument('--expect-sent', dest = 'expect', action = 'store_const', const = 'sent')
|
||||
parser.add_argument('--expect-imap-error', dest = 'expect', action = 'store_const', const = 'imap_error')
|
||||
parser.add_argument('--expect-mailpit-received', dest = 'expect', action = 'store_const', const = 'mailpit_received')
|
||||
parser.add_argument('--expect-mailpit-not-received', dest = 'expect', action = 'store_const', const = 'mailpit_not_received')
|
||||
parser.add_argument('--mailpit-url')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
print(f"got args {args!r}")
|
||||
|
||||
args.header.append(f"Subject: {args.subject}")
|
||||
|
||||
# smtp_starttls = args.smtp_starttls
|
||||
# if smtp_starttls is None:
|
||||
# smtp_starttls = args.submission
|
||||
|
||||
username = args.username
|
||||
password = args.password
|
||||
|
||||
if password is None:
|
||||
password = username
|
||||
|
||||
def mk_ctx():
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
return ctx
|
||||
|
||||
def connection() -> imap_tools.MailBox:
|
||||
return imap_tools.MailBox(args.host, ssl_context = mk_ctx()).login(username, password)
|
||||
|
@@ -220,18 +220,20 @@ in
|
||||
|
||||
liam.wait_for_unit("dovecot2.service")
|
||||
# workaround a bug in dovecot where moving to a not-yet-created but set-to-autocreate mailbox doesn't work
|
||||
liam.succeed("doveadm mailbox create -A INBOX")
|
||||
liam.succeed("doveadm mailbox create -A MagicRefilter")
|
||||
liam.succeed("doveadm mailbox create -u shelvacu INBOX")
|
||||
liam.succeed("doveadm mailbox create -u shelvacu testFolder")
|
||||
liam.succeed("doveadm mailbox create -u shelvacu MagicRefilter")
|
||||
liam.wait_for_unit("postfix.service")
|
||||
relay.wait_for_unit("mailpit.service")
|
||||
|
||||
checks = """
|
||||
# test refilter
|
||||
--mailfrom whoeve2@example.com --rcptto sieve2est@shelvacu.com --username shelvacu --imap-move-to MagicRefilter --imap-dir com.shelvacu
|
||||
# refilter doesnt activate on other folders
|
||||
--mailfrom whoeve2@example.com --rcptto sieve2est@shelvacu.com --username shelvacu --imap-move-to testFolder --imap-dir testFolder
|
||||
--mailfrom whoeve2@example.com --rcptto sieve2est@shelvacu.com --username shelvacu --imap-move-to INBOX --imap-dir INBOX
|
||||
# test the sieve script is working
|
||||
--mailfrom whoever@example.com --rcptto sievetest@shelvacu.com --username shelvacu --imap-dir com.shelvacu
|
||||
# test refilter
|
||||
--mailfrom whoeve2@example.com --rcptto sieve2est@shelvacu.com --username shelvacu --imap-move-to MagicRefilter --imap-dir com.shelvacu
|
||||
# refilter doesnt activate on julie's
|
||||
--mailfrom blarg@example.com --rcptto julie@shelvacu.com --username julie --imap-move-to MagicRefilter --imap-dir MagicRefilter
|
||||
|
||||
|
@@ -135,13 +135,12 @@ if args.expect == 'received' or args.expect == 'imap_error':
|
||||
prefind = find_messages(mailbox)
|
||||
assert len(prefind) > 0, "Could not find message to move anywhere"
|
||||
assert len(prefind) == 1, "Found duplicate messages"
|
||||
mailbox.folder.set(prefind[0].folder)
|
||||
msg = prefind[0].message
|
||||
time.sleep(2)
|
||||
print(f"about to move {msg.uid} to {args.imap_move_to}")
|
||||
mailbox.move(msg.uid, args.imap_move_to)
|
||||
print("done moving")
|
||||
time.sleep(2)
|
||||
print("hopefully the other side is done moving by now")
|
||||
res = mailbox.move(msg.uid, args.imap_move_to)
|
||||
assert res[1][1][1] is not None, "failed to move"
|
||||
print(f"done moving, res {res!r}")
|
||||
with connection() as mailbox:
|
||||
matching_messages = find_messages(mailbox)
|
||||
if args.expect == 'received':
|
||||
|
Reference in New Issue
Block a user