Add a docker-compose spawning Dovecot+Cyrus+Maddy
This commit is contained in:
parent
9675cdb545
commit
e72985a38c
49 changed files with 206 additions and 109 deletions
21
tests/README.md
Normal file
21
tests/README.md
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Spawn Dovecot+Maddy+Cyrus
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker-compose up
|
||||||
|
```
|
||||||
|
|
||||||
|
- Dovecot
|
||||||
|
- listen on :993, run `openssl s_client -connect 127.0.0.1:993`
|
||||||
|
- login with `A LOGIN test pass`
|
||||||
|
- Maddy
|
||||||
|
- listen on :994, run `openssl s_client -connect 127.0.0.1:993`
|
||||||
|
- login with `A LOGIN test@example.com pass`
|
||||||
|
- Cyrus
|
||||||
|
- lient on :143, run `nc 127.0.0.1 143`
|
||||||
|
- login with `A LOGIN test pass`
|
||||||
|
|
||||||
|
# Inject emails and dump the computed `BODY` + `BODYSTRUCTURE`
|
||||||
|
|
||||||
|
Once you ran `docker-compose up`, launch `./send-to-imap.py`
|
22
tests/docker-compose.yml
Normal file
22
tests/docker-compose.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
version: '3.4'
|
||||||
|
services:
|
||||||
|
dovecot:
|
||||||
|
image: dovecot/dovecot:2.3.19.1
|
||||||
|
ports:
|
||||||
|
- "993:993/tcp"
|
||||||
|
|
||||||
|
maddy:
|
||||||
|
build:
|
||||||
|
context: ./docker/maddy/
|
||||||
|
image: maddy
|
||||||
|
ports:
|
||||||
|
- "994:993/tcp"
|
||||||
|
|
||||||
|
cyrus:
|
||||||
|
build:
|
||||||
|
context: ./docker/cyrus/
|
||||||
|
image: cyrus
|
||||||
|
volumes:
|
||||||
|
- "/dev/log:/dev/log"
|
||||||
|
ports:
|
||||||
|
- "143:143/tcp"
|
15
tests/docker/cyrus/Dockerfile
Normal file
15
tests/docker/cyrus/Dockerfile
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
FROM debian:buster
|
||||||
|
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
RUN apt update && \
|
||||||
|
apt install -y cyrus-imapd cyrus-pop3d cyrus-nntpd cyrus-caldav cyrus-admin sasl2-bin && \
|
||||||
|
echo "admins: cyrus" >> /etc/imapd.conf && \
|
||||||
|
touch /var/lib/cyrus/tls_sessions.db && \
|
||||||
|
chown cyrus:mail /var/lib/cyrus/tls_sessions.db && \
|
||||||
|
mkdir /run/cyrus && \
|
||||||
|
chown -R cyrus:mail /run/cyrus
|
||||||
|
|
||||||
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
CMD [ "/usr/local/bin/entrypoint.sh" ]
|
||||||
|
|
15
tests/docker/cyrus/entrypoint.sh
Executable file
15
tests/docker/cyrus/entrypoint.sh
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cyrmaster -D -l 32 -C /etc/imapd.conf -M /etc/cyrus.conf &
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
echo cyrus | saslpasswd2 -p cyrus
|
||||||
|
echo pass | saslpasswd2 -p test
|
||||||
|
|
||||||
|
cyradm -u cyrus -w cyrus 127.0.0.1 <<EOF
|
||||||
|
cm user.test
|
||||||
|
setaclmailbox user.test test kxtelrswip
|
||||||
|
exit
|
||||||
|
EOF
|
||||||
|
|
||||||
|
wait
|
16
tests/docker/maddy/Dockerfile
Normal file
16
tests/docker/maddy/Dockerfile
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
FROM debian:buster as builder
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
|
RUN apt-get update && apt-get install -y openssl && \
|
||||||
|
openssl req -nodes -new -x509 -subj "/C=DW/ST=Sto/L=Ankh-Morpork /O=Unseen University/OU=Library/CN=Ook/emailAddress=ook@ook.ook" -keyout privkey.pem -out fullchain.pem
|
||||||
|
|
||||||
|
FROM foxcpp/maddy:0.6.2
|
||||||
|
|
||||||
|
COPY --from=builder /root/privkey.pem /data/tls/privkey.pem
|
||||||
|
COPY --from=builder /root/fullchain.pem /data/tls/fullchain.pem
|
||||||
|
|
||||||
|
ENV MADDY_DOMAIN=example.com MADDY_HOSTNAME=mx.example.com
|
||||||
|
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
9
tests/docker/maddy/entrypoint.sh
Executable file
9
tests/docker/maddy/entrypoint.sh
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
maddy -config /data/maddy.conf run &
|
||||||
|
|
||||||
|
sleep 2
|
||||||
|
maddyctl creds create --password pass test@example.com
|
||||||
|
maddyctl imap-acct create test@example.com
|
||||||
|
|
||||||
|
wait
|
|
@ -1 +1 @@
|
||||||
(BODY (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1)("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "8BIT" 16 1) "ALTERNATIVE"))
|
(BODY (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1)("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "8BIT" 14 0) "ALTERNATIVE"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1 NIL NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "8BIT" 16 1 NIL NIL NIL NIL) "ALTERNATIVE" ("BOUNDARY" "festivus") NIL NIL NIL))
|
(BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1 NIL NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "8BIT" 14 0 NIL NIL NIL NIL) "ALTERNATIVE" ("BOUNDARY" "festivus") NIL NIL NIL))
|
|
@ -1 +1 @@
|
||||||
(BODY (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1)("text" "html" ("charset" "utf-8") NIL NIL "8bit" 16 1) "alternative"))
|
(BODY (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1)("text" "html" ("charset" "utf-8") NIL NIL "8bit" 14 0) "alternative"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL)("text" "html" ("charset" "utf-8") NIL NIL "8bit" 16 1 NIL NIL NIL NIL) "alternative" ("boundary" "festivus") NIL NIL NIL))
|
(BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL)("text" "html" ("charset" "utf-8") NIL NIL "8bit" 14 0 NIL NIL NIL NIL) "alternative" ("boundary" "festivus") NIL NIL NIL))
|
|
@ -13,5 +13,4 @@ Content-Type: text/html; charset="utf-8"
|
||||||
Content-Transfer-Encoding: 8bit
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
<p>Hello 2</p>
|
<p>Hello 2</p>
|
||||||
|
|
||||||
--festivus--
|
--festivus--
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
(BODY (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1) ("text" "html" ("charset" "utf-8") NIL NIL "8bit" 16 1) "alternative"))
|
(BODY (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1) ("text" "html" ("charset" "utf-8") NIL NIL "8bit" 14 1) "alternative"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL) ("text" "html" ("charset" "utf-8") NIL NIL "8bit" 16 1 NIL NIL NIL NIL) "alternative" ("boundary" "festivus") NIL NIL NIL))
|
(BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL) ("text" "html" ("charset" "utf-8") NIL NIL "8bit" 14 1 NIL NIL NIL NIL) "alternative" ("boundary" "festivus") NIL NIL NIL))
|
|
@ -1 +1 @@
|
||||||
(BODY ((("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1)("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1) "MIXED")("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1) "MIXED"))
|
(BODY ((("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1)("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 7 0) "MIXED")("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 7 0) "MIXED"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE ((("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1 NIL NIL NIL NIL)("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1 NIL NIL NIL NIL) "MIXED" ("BOUNDARY" "child") NIL NIL NIL)("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1 NIL NIL NIL NIL) "MIXED" ("BOUNDARY" "parent") NIL NIL NIL))
|
(BODYSTRUCTURE ((("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1 NIL NIL NIL NIL)("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 7 0 NIL NIL NIL NIL) "MIXED" ("BOUNDARY" "child") NIL NIL NIL)("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 7 0 NIL NIL NIL NIL) "MIXED" ("BOUNDARY" "parent") NIL NIL NIL))
|
|
@ -1 +1 @@
|
||||||
(BODY ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1) "mixed")("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1) "mixed"))
|
(BODY ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0) "mixed")("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0) "mixed"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL) "mixed" ("boundary" "child") NIL NIL NIL)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL) "mixed" ("boundary" "parent") NIL NIL NIL))
|
(BODYSTRUCTURE ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0 NIL NIL NIL NIL) "mixed" ("boundary" "child") NIL NIL NIL)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0 NIL NIL NIL NIL) "mixed" ("boundary" "parent") NIL NIL NIL))
|
|
@ -14,11 +14,9 @@ Hello 1
|
||||||
Content-Type: text/plain; charset="us-ascii"
|
Content-Type: text/plain; charset="us-ascii"
|
||||||
|
|
||||||
Hello 2
|
Hello 2
|
||||||
|
|
||||||
--child--
|
--child--
|
||||||
--parent
|
--parent
|
||||||
Content-Type: text/plain; charset="us-ascii"
|
Content-Type: text/plain; charset="us-ascii"
|
||||||
|
|
||||||
Hello 3
|
Hello 3
|
||||||
|
|
||||||
--parent--
|
--parent--
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
(BODY ((("text" "plain" ("charset" "us-ascii") NIL NIL NIL 9 1) ("text" "plain" ("charset" "us-ascii") NIL NIL NIL 9 1) "mixed") ("text" "plain" ("charset" "us-ascii") NIL NIL NIL 9 1) "mixed"))
|
(BODY ((("text" "plain" ("charset" "us-ascii") NIL NIL NIL 9 1) ("text" "plain" ("charset" "us-ascii") NIL NIL NIL 7 1) "mixed") ("text" "plain" ("charset" "us-ascii") NIL NIL NIL 7 1) "mixed"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE ((("text" "plain" ("charset" "us-ascii") NIL NIL NIL 9 1 NIL NIL NIL NIL) ("text" "plain" ("charset" "us-ascii") NIL NIL NIL 9 1 NIL NIL NIL NIL) "mixed" ("boundary" "child") NIL NIL NIL) ("text" "plain" ("charset" "us-ascii") NIL NIL NIL 9 1 NIL NIL NIL NIL) "mixed" ("boundary" "parent") NIL NIL NIL))
|
(BODYSTRUCTURE ((("text" "plain" ("charset" "us-ascii") NIL NIL NIL 9 1 NIL NIL NIL NIL) ("text" "plain" ("charset" "us-ascii") NIL NIL NIL 7 1 NIL NIL NIL NIL) "mixed" ("boundary" "child") NIL NIL NIL) ("text" "plain" ("charset" "us-ascii") NIL NIL NIL 7 1 NIL NIL NIL NIL) "mixed" ("boundary" "parent") NIL NIL NIL))
|
|
@ -1 +1 @@
|
||||||
(BODY (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 49 1) 4) "MIXED"))
|
(BODY (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 7 0)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 49 1) 4) "MIXED"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 9 1 NIL NIL NIL NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 49 1 NIL NIL NIL NIL) 4 NIL NIL NIL NIL) "MIXED" ("BOUNDARY" "delim") NIL NIL NIL))
|
(BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 7 0 NIL NIL NIL NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 49 1 NIL NIL NIL NIL) 4 NIL NIL NIL NIL) "MIXED" ("BOUNDARY" "delim") NIL NIL NIL))
|
|
@ -1 +1 @@
|
||||||
(BODY (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1)("message" "rfc822" NIL NIL NIL "7bit" 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 49 1) 4) "mixed"))
|
(BODY (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0)("message" "rfc822" NIL NIL NIL "7bit" 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 49 1) 4) "mixed"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL)("message" "rfc822" NIL NIL NIL "7bit" 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 49 1 NIL NIL NIL NIL) 4 NIL NIL NIL NIL) "mixed" ("boundary" "delim") NIL NIL NIL))
|
(BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0 NIL NIL NIL NIL)("message" "rfc822" NIL NIL NIL "7bit" 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 49 1 NIL NIL NIL NIL) 4 NIL NIL NIL NIL) "mixed" ("boundary" "delim") NIL NIL NIL))
|
|
@ -6,7 +6,6 @@ Subject: Welcome to Aerogramme!!
|
||||||
Content-Type: text/plain; charset="us-ascii"
|
Content-Type: text/plain; charset="us-ascii"
|
||||||
|
|
||||||
Hello 1
|
Hello 1
|
||||||
|
|
||||||
--delim
|
--delim
|
||||||
Content-Type: message/rfc822
|
Content-Type: message/rfc822
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
(BODY (("text" "plain" ("charset" "us-ascii") NIL NIL NIL 9 1) ("message" "rfc822" () NIL NIL NIL 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" () NIL NIL NIL 49 1 NIL NIL NIL NIL) 4) "mixed"))
|
(BODY (("text" "plain" ("charset" "us-ascii") NIL NIL NIL 7 1) ("message" "rfc822" () NIL NIL NIL 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" () NIL NIL NIL 49 1 NIL NIL NIL NIL) 4) "mixed"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL NIL 9 1 NIL NIL NIL NIL) ("message" "rfc822" () NIL NIL NIL 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" () NIL NIL NIL 49 1 NIL NIL NIL NIL) 4 NIL NIL NIL NIL) "mixed" ("boundary" "delim") NIL NIL NIL))
|
(BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL NIL 7 1 NIL NIL NIL NIL) ("message" "rfc822" () NIL NIL NIL 129 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" () NIL NIL NIL 49 1 NIL NIL NIL NIL) 4 NIL NIL NIL NIL) "mixed" ("boundary" "delim") NIL NIL NIL))
|
|
@ -1 +1 @@
|
||||||
(BODY (("TEXT" "HTML" ("CHARSET" "us-ascii") NIL NIL "BASE64" 242 3)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 744 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("TEXT" "PLAIN" ("CHARSET" "utf-16") NIL NIL "QUOTED-PRINTABLE" 231 3)("IMAGE" "GIF" ("NAME" "Book about ") NIL NIL "BASE64" 56) "MIXED") 20) "MIXED"))
|
(BODY (("TEXT" "HTML" ("CHARSET" "us-ascii") NIL NIL "BASE64" 242 3)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 734 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("TEXT" "PLAIN" ("CHARSET" "utf-16") NIL NIL "QUOTED-PRINTABLE" 231 3)("IMAGE" "GIF" ("NAME" "Book about coffe tables.gif") NIL NIL "BASE64" 56) "MIXED") 20) "MIXED"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE (("TEXT" "HTML" ("CHARSET" "us-ascii") NIL NIL "BASE64" 242 3 NIL NIL NIL NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 744 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("TEXT" "PLAIN" ("CHARSET" "utf-16") NIL NIL "QUOTED-PRINTABLE" 231 3 NIL NIL NIL NIL)("IMAGE" "GIF" ("NAME" "Book about ") NIL NIL "BASE64" 56 NIL ("ATTACHMENT" NIL) NIL NIL) "MIXED" ("BOUNDARY" "giddyup") NIL NIL NIL) 20 NIL NIL NIL NIL) "MIXED" ("BOUNDARY" "festivus") NIL NIL NIL))
|
(BODYSTRUCTURE (("TEXT" "HTML" ("CHARSET" "us-ascii") NIL NIL "BASE64" 242 3 NIL NIL NIL NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 734 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("TEXT" "PLAIN" ("CHARSET" "utf-16") NIL NIL "QUOTED-PRINTABLE" 231 3 NIL NIL NIL NIL)("IMAGE" "GIF" ("NAME" "Book about coffe tables.gif") NIL NIL "BASE64" 56 NIL ("ATTACHMENT" NIL) NIL NIL) "MIXED" ("BOUNDARY" "giddyup") NIL NIL NIL) 20 NIL NIL NIL NIL) "MIXED" ("BOUNDARY" "festivus") NIL NIL NIL))
|
|
@ -1 +1 @@
|
||||||
(BODY (("text" "html" ("charset" "us-ascii") NIL NIL "base64" 242 3)("message" "rfc822" NIL NIL NIL "7bit" 744 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("text" "plain" ("charset" "utf-16") NIL NIL "quoted-printable" 231 3)("image" "gif" ("name*" "''Book about utf-8''%e2%98%95") NIL NIL "Base64" 56) "mixed") 20) "mixed"))
|
(BODY (("text" "html" ("charset" "us-ascii") NIL NIL "base64" 242 3)("message" "rfc822" NIL NIL NIL "7bit" 734 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("text" "plain" ("charset" "utf-16") NIL NIL "quoted-printable" 231 3)("image" "gif" ("name" "Book about coffe tables.gif") NIL NIL "Base64" 56) "mixed") 20) "mixed"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE (("text" "html" ("charset" "us-ascii") NIL NIL "base64" 242 3 NIL NIL NIL NIL)("message" "rfc822" NIL NIL NIL "7bit" 744 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("text" "plain" ("charset" "utf-16") NIL NIL "quoted-printable" 231 3 NIL NIL NIL NIL)("image" "gif" ("name*" "''Book about utf-8''%e2%98%95") NIL NIL "Base64" 56 NIL ("attachment" NIL) NIL NIL) "mixed" ("boundary" "giddyup") NIL NIL NIL) 20 NIL NIL NIL NIL) "mixed" ("boundary" "festivus") NIL NIL NIL))
|
(BODYSTRUCTURE (("text" "html" ("charset" "us-ascii") NIL NIL "base64" 242 3 NIL NIL NIL NIL)("message" "rfc822" NIL NIL NIL "7bit" 734 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("text" "plain" ("charset" "utf-16") NIL NIL "quoted-printable" 231 3 NIL NIL NIL NIL)("image" "gif" ("name" "Book about coffe tables.gif") NIL NIL "Base64" 56 NIL ("attachment" NIL) NIL NIL) "mixed" ("boundary" "giddyup") NIL NIL NIL) 20 NIL NIL NIL NIL) "mixed" ("boundary" "festivus") NIL NIL NIL))
|
|
@ -2,7 +2,7 @@ From: Art Vandelay <art@vandelay.com> (Vandelay Industries)
|
||||||
To: "Colleagues": "James Smythe" <james@vandelay.com>; Friends:
|
To: "Colleagues": "James Smythe" <james@vandelay.com>; Friends:
|
||||||
jane@example.com, =?UTF-8?Q?John_Sm=C3=AEth?= <john@example.com>;
|
jane@example.com, =?UTF-8?Q?John_Sm=C3=AEth?= <john@example.com>;
|
||||||
Date: Sat, 20 Nov 2021 14:22:01 -0800
|
Date: Sat, 20 Nov 2021 14:22:01 -0800
|
||||||
Subject: Why not both importing AND exporting? =?utf-8?b?4pi6?=
|
Subject: Why not both importing AND exporting?
|
||||||
Content-Type: multipart/mixed; boundary="festivus";
|
Content-Type: multipart/mixed; boundary="festivus";
|
||||||
|
|
||||||
--festivus
|
--festivus
|
||||||
|
@ -30,7 +30,7 @@ Content-Transfer-Encoding: quoted-printable
|
||||||
=DD5=D8=1E=DD5=D80=DD5=D8"=DD!=00
|
=DD5=D8=1E=DD5=D80=DD5=D8"=DD!=00
|
||||||
--giddyup
|
--giddyup
|
||||||
Content-Type: image/gif; name*1="about "; name*0="Book ";
|
Content-Type: image/gif; name*1="about "; name*0="Book ";
|
||||||
name*2*=utf-8''%e2%98%95 tables.gif
|
name*2="coffe tables.gif"
|
||||||
Content-Transfer-Encoding: Base64
|
Content-Transfer-Encoding: Base64
|
||||||
Content-Disposition: attachment
|
Content-Disposition: attachment
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
(BODY (("text" "html" ("charset" "us-ascii") NIL NIL "base64" 242 4) ("message" "rfc822" () NIL NIL NIL 742 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("text" "plain" ("charset" "utf-16") NIL NIL "quoted-printable" 231 4 NIL NIL NIL NIL) ("text" "plain" () NIL NIL "Base64" 56 1 NIL ("attachment" ()) NIL NIL) "mixed" ("boundary" "giddyup") NIL NIL NIL) 21) "mixed"))
|
(BODY (("text" "html" ("charset" "us-ascii") NIL NIL "base64" 242 4) ("message" "rfc822" () NIL NIL NIL 732 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("text" "plain" ("charset" "utf-16") NIL NIL "quoted-printable" 231 4 NIL NIL NIL NIL) ("image" "gif" ("name" "Book about coffe tables.gif") NIL NIL "Base64" 56 NIL ("attachment" ()) NIL NIL) "mixed" ("boundary" "giddyup") NIL NIL NIL) 21) "mixed"))
|
|
@ -1 +1 @@
|
||||||
(BODYSTRUCTURE (("text" "html" ("charset" "us-ascii") NIL NIL "base64" 242 4 NIL NIL NIL NIL) ("message" "rfc822" () NIL NIL NIL 742 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("text" "plain" ("charset" "utf-16") NIL NIL "quoted-printable" 231 4 NIL NIL NIL NIL) ("text" "plain" () NIL NIL "Base64" 56 1 NIL ("attachment" ()) NIL NIL) "mixed" ("boundary" "giddyup") NIL NIL NIL) 21 NIL NIL NIL NIL) "mixed" ("boundary" "festivus") NIL NIL NIL))
|
(BODYSTRUCTURE (("text" "html" ("charset" "us-ascii") NIL NIL "base64" 242 4 NIL NIL NIL NIL) ("message" "rfc822" () NIL NIL NIL 732 (NIL "Exporting my book about coffee tables" (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) (("Cosmo Kramer" NIL "kramer" "kramerica.com")) NIL NIL NIL NIL NIL) (("text" "plain" ("charset" "utf-16") NIL NIL "quoted-printable" 231 4 NIL NIL NIL NIL) ("image" "gif" ("name" "Book about coffe tables.gif") NIL NIL "Base64" 56 NIL ("attachment" ()) NIL NIL) "mixed" ("boundary" "giddyup") NIL NIL NIL) 21 NIL NIL NIL NIL) "mixed" ("boundary" "festivus") NIL NIL NIL))
|
1
tests/emails/dxflrs/0006_single-mime.cyrus.body
Normal file
1
tests/emails/dxflrs/0006_single-mime.cyrus.body
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(BODY (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 7 0) "ALTERNATIVE"))
|
1
tests/emails/dxflrs/0006_single-mime.cyrus.bodystructure
Normal file
1
tests/emails/dxflrs/0006_single-mime.cyrus.bodystructure
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 7 0 NIL NIL NIL NIL) "ALTERNATIVE" ("BOUNDARY" "festivus") NIL NIL NIL))
|
1
tests/emails/dxflrs/0006_single-mime.dovecot.body
Normal file
1
tests/emails/dxflrs/0006_single-mime.dovecot.body
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(BODY (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0) "alternative"))
|
|
@ -0,0 +1 @@
|
||||||
|
(BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0 NIL NIL NIL NIL) "alternative" ("boundary" "festivus") NIL NIL NIL))
|
10
tests/emails/dxflrs/0006_single-mime.eml
Normal file
10
tests/emails/dxflrs/0006_single-mime.eml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
From: Garage team <garagehq@deuxfleurs.fr>
|
||||||
|
Content-Type: multipart/alternative; boundary="festivus";
|
||||||
|
Subject: Welcome to Aerogramme!!
|
||||||
|
|
||||||
|
--festivus
|
||||||
|
Content-Type: text/plain; charset="us-ascii"
|
||||||
|
Content-Transfer-Encoding: 7bit
|
||||||
|
|
||||||
|
Hello 1
|
||||||
|
--festivus--
|
1
tests/emails/dxflrs/0006_single-mime.maddy.body
Normal file
1
tests/emails/dxflrs/0006_single-mime.maddy.body
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(BODY (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 1) "alternative"))
|
1
tests/emails/dxflrs/0006_single-mime.maddy.bodystructure
Normal file
1
tests/emails/dxflrs/0006_single-mime.maddy.bodystructure
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 1 NIL NIL NIL NIL) "alternative" ("boundary" "festivus") NIL NIL NIL))
|
1
tests/emails/dxflrs/0007_raw_msg_in_rfc822.cyrus.body
Normal file
1
tests/emails/dxflrs/0007_raw_msg_in_rfc822.cyrus.body
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(BODY (("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 127 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 47 0) 3) "MIXED"))
|
|
@ -0,0 +1 @@
|
||||||
|
(BODYSTRUCTURE (("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 127 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 47 0 NIL NIL NIL NIL) 3 NIL NIL NIL NIL) "MIXED" ("BOUNDARY" "delim") NIL NIL NIL))
|
1
tests/emails/dxflrs/0007_raw_msg_in_rfc822.dovecot.body
Normal file
1
tests/emails/dxflrs/0007_raw_msg_in_rfc822.dovecot.body
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(BODY (("message" "rfc822" NIL NIL NIL "7bit" 127 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 47 0) 3) "mixed"))
|
|
@ -0,0 +1 @@
|
||||||
|
(BODYSTRUCTURE (("message" "rfc822" NIL NIL NIL "7bit" 127 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 47 0 NIL NIL NIL NIL) 3 NIL NIL NIL NIL) "mixed" ("boundary" "delim") NIL NIL NIL))
|
12
tests/emails/dxflrs/0007_raw_msg_in_rfc822.eml
Normal file
12
tests/emails/dxflrs/0007_raw_msg_in_rfc822.eml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
From: Garage team <garagehq@deuxfleurs.fr>
|
||||||
|
Content-Type: multipart/mixed; boundary="delim";
|
||||||
|
Subject: Welcome to Aerogramme!!
|
||||||
|
|
||||||
|
--delim
|
||||||
|
Content-Type: message/rfc822
|
||||||
|
|
||||||
|
From: Garage team <garagehq@deuxfleurs.fr>
|
||||||
|
Subject: Welcome to Aerogramme!!
|
||||||
|
|
||||||
|
This is just a test email, feel free to ignore.
|
||||||
|
--delim--
|
1
tests/emails/dxflrs/0007_raw_msg_in_rfc822.maddy.body
Normal file
1
tests/emails/dxflrs/0007_raw_msg_in_rfc822.maddy.body
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(BODY (("message" "rfc822" () NIL NIL NIL 127 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" () NIL NIL NIL 47 1 NIL NIL NIL NIL) 5) "mixed"))
|
|
@ -0,0 +1 @@
|
||||||
|
(BODYSTRUCTURE (("message" "rfc822" () NIL NIL NIL 127 (NIL "Welcome to Aerogramme!!" (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) (("Garage team" NIL "garagehq" "deuxfleurs.fr")) NIL NIL NIL NIL NIL) ("text" "plain" () NIL NIL NIL 47 1 NIL NIL NIL NIL) 5 NIL NIL NIL NIL) "mixed" ("boundary" "delim") NIL NIL NIL))
|
|
@ -5,56 +5,11 @@ import sys
|
||||||
|
|
||||||
# COMMAND USAGE
|
# COMMAND USAGE
|
||||||
#
|
#
|
||||||
# start a test IMAP server locally (see comment below)
|
# start a test IMAP servers:
|
||||||
|
# docker-compose.up
|
||||||
# then call this script. eg:
|
# then call this script. eg:
|
||||||
# ./send-to-imap.py dovecot ./emails/dxflrs/
|
# ./send-to-imap.py all ./emails/dxflrs/
|
||||||
|
|
||||||
# DOCKER CONTAINERS TO QUICKLY SPAWN A REFERENCE SERVER
|
|
||||||
#
|
|
||||||
# -- Dovecot --
|
|
||||||
# cmd: docker run --rm -it -p 993:993 -p 143:143 dovecot/dovecot
|
|
||||||
# user: test (any)
|
|
||||||
# pw: pass
|
|
||||||
#
|
|
||||||
# -- Maddy --
|
|
||||||
# cmds:
|
|
||||||
# docker volume create maddydata
|
|
||||||
# openssl req -nodes -new -x509 -keyout privkey.pem -out fullchain.pem
|
|
||||||
# docker run --rm -it --name maddy -e MADDY_DOMAIN=example.com -e MADDY_HOSTNAME=mx.example.com -v maddydata:/data -p 143:143 -p 993:993 --entrypoint /bin/sh foxcpp/maddy
|
|
||||||
# mkdir /data/tls
|
|
||||||
# docker cp ./fullchain.pem maddy:/data/tls/
|
|
||||||
# docker cp ./privkey.pem maddy:/data/tls/
|
|
||||||
# maddyctl creds create test@example.com
|
|
||||||
# maddyctl imap-acct create test@example.com
|
|
||||||
# maddy -config /data/maddy.conf run --debug
|
|
||||||
#
|
|
||||||
# docker run --rm -it -v maddydata:/data-p 143:143 -p 993:993 foxcpp/maddy
|
|
||||||
#
|
|
||||||
# -- Cyrus --
|
|
||||||
# docker run --rm -it --name cyrus -v /dev/log:/dev/log -p 143:143 -p 993:993 debian:buster
|
|
||||||
# apt update; apt install -y cyrus-imapd cyrus-pop3d cyrus-nntpd cyrus-caldav cyrus-admin sasl2-bin vim
|
|
||||||
# # ( 1. No Configuration / 8. Europe / 37. Paris / yes)
|
|
||||||
# vim /etc/imapd.conf
|
|
||||||
# # (uncomment 'admins: cyrus')
|
|
||||||
# touch /var/lib/cyrus/tls_sessions.db
|
|
||||||
# chown cyrus:mail /var/lib/cyrus/tls_sessions.db
|
|
||||||
# mkdir /run/cyrus
|
|
||||||
# chown -R cyrus:mail /run/cyrus
|
|
||||||
# cyrmaster -D -l 32 -C /etc/imapd.conf -M /etc/cyrus.conf
|
|
||||||
# docker exec -ti --name cyrus /bin/bash
|
|
||||||
# saslpasswd2 cyrus
|
|
||||||
# # (put "cyrus" as password)
|
|
||||||
# saslpasswd2 test
|
|
||||||
# # (put "pass" as password)
|
|
||||||
# cyradm -u cyrus localhost
|
|
||||||
# cm kzUXL7HyS5OjLcU8
|
|
||||||
# setaclmailbox kzUXL7HyS5OjLcU8 test ktelrswip
|
|
||||||
#
|
|
||||||
# -> note, must be run between 2 send-imap commands in cyradm
|
|
||||||
# localhost> setaclmailbox kzUXL7HyS5OjLcU8 cyrus x
|
|
||||||
# localhost> dm kzUXL7HyS5OjLcU8
|
|
||||||
# localhost> cm kzUXL7HyS5OjLcU8
|
|
||||||
# localhost> setaclmailbox kzUXL7HyS5OjLcU8 test ktelrswip
|
|
||||||
|
|
||||||
def rebuild_body_res(b):
|
def rebuild_body_res(b):
|
||||||
bb = b''
|
bb = b''
|
||||||
|
@ -67,65 +22,79 @@ def rebuild_body_res(b):
|
||||||
f = bb[bb.find(b'('):]
|
f = bb[bb.find(b'('):]
|
||||||
return f
|
return f
|
||||||
|
|
||||||
target = sys.argv[1]
|
mode = sys.argv[1]
|
||||||
path = sys.argv[2]
|
path = sys.argv[2]
|
||||||
|
|
||||||
|
base_test_mb = "kzUXL7HyS5OjLcU8"
|
||||||
parameters = {
|
parameters = {
|
||||||
"dovecot": {
|
"dovecot": {
|
||||||
"con": IMAP4_SSL,
|
"con": IMAP4_SSL,
|
||||||
|
"port": 993,
|
||||||
"user": "test",
|
"user": "test",
|
||||||
"pw": "pass",
|
"pw": "pass",
|
||||||
"ext": ".dovecot",
|
"ext": ".dovecot",
|
||||||
|
"mb": base_test_mb,
|
||||||
},
|
},
|
||||||
"maddy": {
|
"maddy": {
|
||||||
"con": IMAP4_SSL,
|
"con": IMAP4_SSL,
|
||||||
|
"port": 994,
|
||||||
"user": "test@example.com",
|
"user": "test@example.com",
|
||||||
"pw": "pass",
|
"pw": "pass",
|
||||||
"ext": ".maddy",
|
"ext": ".maddy",
|
||||||
|
"mb": base_test_mb,
|
||||||
},
|
},
|
||||||
"cyrus": {
|
"cyrus": {
|
||||||
"con": IMAP4,
|
"con": IMAP4,
|
||||||
|
"port": 143,
|
||||||
"user": "test",
|
"user": "test",
|
||||||
"pw": "pass",
|
"pw": "pass",
|
||||||
"ext": ".cyrus",
|
"ext": ".cyrus",
|
||||||
|
"mb": "INBOX."+base_test_mb,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conf = parameters[target]
|
|
||||||
|
queue = list(parameters.keys())
|
||||||
|
if mode in parameters:
|
||||||
|
queue = [ mode ]
|
||||||
|
|
||||||
onlyfiles = [join(path, f) for f in listdir(path) if isfile(join(path, f)) and len(f) > 4 and f[-4:] == ".eml"]
|
onlyfiles = [join(path, f) for f in listdir(path) if isfile(join(path, f)) and len(f) > 4 and f[-4:] == ".eml"]
|
||||||
|
|
||||||
test_mb = "kzUXL7HyS5OjLcU8"
|
for target in queue:
|
||||||
with conf['con'](host="localhost") as M:
|
print(f"--- {target} ---")
|
||||||
print(M.login(conf['user'], conf['pw']))
|
conf = parameters[target]
|
||||||
print(M.delete(test_mb))
|
test_mb = conf['mb']
|
||||||
print(M.create(test_mb))
|
|
||||||
|
with conf['con'](host="localhost", port=conf['port']) as M:
|
||||||
|
print(M.login(conf['user'], conf['pw']))
|
||||||
|
print(M.delete(test_mb))
|
||||||
|
print(M.create(test_mb))
|
||||||
|
|
||||||
|
|
||||||
print(M.list())
|
print(M.list())
|
||||||
print(M.select(test_mb))
|
print(M.select(test_mb))
|
||||||
failed = 0
|
failed = 0
|
||||||
for (idx, f) in enumerate(onlyfiles):
|
for (idx, f) in enumerate(onlyfiles):
|
||||||
f_noext = f[:-4]
|
f_noext = f[:-4]
|
||||||
try:
|
try:
|
||||||
with open(f, 'r+b') as mail:
|
with open(f, 'r+b') as mail:
|
||||||
print(M.append(test_mb, [], None, mail.read()))
|
print(M.append(test_mb, [], None, mail.read()))
|
||||||
seq = (f"{idx+1-failed}:{idx+1-failed}").encode()
|
seq = (f"{idx+1-failed}:{idx+1-failed}").encode()
|
||||||
(r, b) = M.fetch(seq, "(BODY)")
|
(r, b) = M.fetch(seq, "(BODY)")
|
||||||
print((r, b))
|
print((r, b))
|
||||||
assert r == 'OK'
|
assert r == 'OK'
|
||||||
|
|
||||||
|
|
||||||
with open(f_noext + conf['ext'] + ".body", 'w+b') as w:
|
with open(f_noext + conf['ext'] + ".body", 'w+b') as w:
|
||||||
w.write(rebuild_body_res(b))
|
w.write(rebuild_body_res(b))
|
||||||
|
|
||||||
(r, b) = M.fetch(seq, "(BODYSTRUCTURE)")
|
(r, b) = M.fetch(seq, "(BODYSTRUCTURE)")
|
||||||
print((r, b))
|
print((r, b))
|
||||||
assert r == 'OK'
|
assert r == 'OK'
|
||||||
with open(f_noext + conf['ext'] + ".bodystructure", 'w+b') as w:
|
with open(f_noext + conf['ext'] + ".bodystructure", 'w+b') as w:
|
||||||
w.write(rebuild_body_res(b))
|
w.write(rebuild_body_res(b))
|
||||||
except:
|
except:
|
||||||
failed += 1
|
failed += 1
|
||||||
print(f"failed {f}")
|
print(f"failed {f}")
|
||||||
|
|
||||||
M.close()
|
M.close()
|
||||||
M.logout()
|
M.logout()
|
||||||
|
|
Loading…
Reference in a new issue