Browse Source

update sub unsub emails and fix handling double/triple banners

Pi 1 year ago
parent
commit
5c356520f8

+ 2 - 1
cropswap-members@shandan.one/SUBSCRIBE.eml

@@ -1,10 +1,11 @@
 <html><head></head><body>
 <p>You have been successfully subscribed to the Taupiri Crop Swap Members mailing list.
+<p>This mailing list is like a bulletin board that any subscribed member may post a question or comment on.
 <p>Email sent to <a href="mailto:cropswap-members@shandan.one">cropswap-members@shandan.one</a> will be forwarded to all other subscribed members.
 <p>When you reply to an email from the mailing list, only the sender will receive it.
 <p>If you would like to send an email to all the members, then start a new email thread addressed to: <a href="mailto:cropswap-members@shandan.one">cropswap-members@shandan.one</a>
 <p>To unsubscribe click <a href="mailto:cropswap-members@shandan.one?subject=[UNSUBSCRIBE]">here</a>.
-<p>You may unsubscribe from this list at any time by clicking the unsubscribe link at the bottom of any mail you receive, or by sending an email to <a href="mailto:cropswap-members@shandan.one">cropswap-members@shandan.one</a>, with [UNSUBSCRIBE] as the subject (square brackets included). For example:
+<p>Alternatively, you may unsubscribe from this list at any time by clicking the unsubscribe link at the bottom of any mail you receive, or by sending an email to <a href="mailto:cropswap-members@shandan.one">cropswap-members@shandan.one</a>, with [UNSUBSCRIBE] as the subject (square brackets included). For example:
 <p><pre>
 To:      cropswap-members@shandan.one
 Subject: [UNSUBSCRIBE]

+ 2 - 2
cropswap-members@shandan.one/UNSUBSCRIBE.eml

@@ -1,10 +1,10 @@
 <html><head></head><body>
 <p>You have been successfully unsubscribed from the Taupiri Crop Swap Members mailing list.
 <p>You will no longer receive email from <a href="mailto:cropswap-members@shandan.one">cropswap-members@shandan.one</a>.
-<p>If you wish to continue receiveing messages from other members, then you may <a href="mailto:cropswap-members@shandan.one?subject=[SUBSCRIBE]">subscribe</a> at any time by sending an email to <a href="mailto:cropswap-members@shandan.one">cropswap-members@shandan.one</a>, with [SUBSCRIBE] as the subject (square brackets included). For example:
+<p>If you wish to continue receiving messages from other members, then you may <a href="mailto:cropswap-members@shandan.one?subject=[SUBSCRIBE]">subscribe</a> at any time by sending an email to <a href="mailto:cropswap-members@shandan.one">cropswap-members@shandan.one</a>, with [SUBSCRIBE] as the subject (square brackets included). For example:
 <p><pre>
 To:      cropswap-members@shandan.one
 Subject: [SUBSCRIBE]
 </pre>
-<p>You may also contact the orgnizers for assistance by sending an e-mail to <a href="mailto:cropswap@shandan.one">cropswap@shandan.one</a>
+<p>You may also contact the organizers for assistance by sending an e-mail to <a href="mailto:cropswap@shandan.one">cropswap@shandan.one</a>
 </body></html>

+ 2 - 3
cropswap@shandan.one/SUBSCRIBE.eml

@@ -1,10 +1,9 @@
 <html><head></head><body>
 <p>You have been successfully subscribed to the Taupiri Crop Swap Notices mailing list.
+<p>This mailing list is only for announcements and updates from the Taupiri Crop Swap organizers.
 <p>Email sent to <a href="mailto:cropswap@shandan.one">cropswap@shandan.one</a> will be forwarded to the organizers only.
-<p>When you reply to an email from the mailing list, only the sender will receive it.
-<p>If you would like to send an email to all the organizers, then start a new email thread addressed to: <a href="mailto:cropswap@shandan.one">cropswap@shandan.one</a>
 <p>To unsubscribe click <a href="mailto:cropswap@shandan.one?subject=[UNSUBSCRIBE]">here</a>.
-<p>You may also unsubscribe at any time by clicking the unsubscribe link at the bottom of any mail you receive, or by sending an email to <a href="mailto:cropswap@shandan.one">cropswap@shandan.one</a>, with [UNSUBSCRIBE] as the subject (square brackets included). For example:
+<p>Alternatively, you may unsubscribe at any time by clicking the unsubscribe link at the bottom of any mail you receive, or by sending an email to <a href="mailto:cropswap@shandan.one">cropswap@shandan.one</a>, with [UNSUBSCRIBE] as the subject (square brackets included). For example:
 <p><pre>
 To:      cropswap@shandan.one
 Subject: [UNSUBSCRIBE]

+ 2 - 2
cropswap@shandan.one/UNSUBSCRIBE.eml

@@ -2,10 +2,10 @@
 <p>You have been successfully unsubscribed from the Taupiri Crop Swap Notices mailing list.
 <p>You will no longer receive email from <a href="cropswap@shandan.one">cropswap@shandan.one</a>
 <p>This includes any notices, updates, and announcements from the Taupiri Crop Swap organizers.
-<p>If you wish to continue receiveing announcements or updates, then you may <a href="mailto:cropswap@shandan.one?subject=[SUBSCRIBE]">subscribe</a> again at any time by sending an email to <a href="mailto:cropswap@shandan.one">cropswap@shandan.one</a>, with [SUBSCRIBE] as the subject (square brackets included). For example:
+<p>If you wish to continue receiving announcements or updates, then you may <a href="mailto:cropswap@shandan.one?subject=[SUBSCRIBE]">subscribe</a> again at any time by sending an email to <a href="mailto:cropswap@shandan.one">cropswap@shandan.one</a>, with [SUBSCRIBE] as the subject (square brackets included). For example:
 <p><pre>
 To:      cropswap@shandan.one
 Subject: [SUBSCRIBE]
 </pre>
-<p>You may also contact the orgnizers for assistance by sending an e-mail to <a href="mailto:cropswap@shandan.one">cropswap@shandan.one</a>
+<p>You may also contact the organizers for assistance by sending an e-mail to <a href="mailto:cropswap@shandan.one">cropswap@shandan.one</a>
 </body></html>

+ 16 - 1
mime-inject.py

@@ -1,6 +1,18 @@
 #!/usr/bin/env python3
 import sys
 import email
+from lxml import html as HTML
+
+def iter(e):
+    yield e
+    for _e in e.iterchildren():
+        yield from iter(_e)
+
+def drop_banner(h):
+    for e in iter(h):
+        if any((x in e.attrib.get('id', []) for x in ('cropswap-banner', 'cropswap-members-banner'))):
+            e.drop_tree()
+    return HTML.tostring(h).decode("utf-8")
 
 mailgroup = sys.argv[1]
 try:
@@ -23,12 +35,15 @@ def inject(m):
     c = m.get_content_type()
     e = m.get('Content-Transfer-Encoding','').lower()
     payload = m.get_payload(decode=True).decode("utf-8")
+
     if c == 'text/plain' and txt not in payload:
         payload = payload + f"""
 {txt}
 """
     if c == 'text/html':
-        payload = payload.replace(html, '')
+        h = HTML.fromstring(payload)
+        payload = drop_banner(h)
+
         if '</body>' in payload:
             payload = payload.replace('</body>', f'{html}</body>')
         else: