changeset 44:737cd0fd5adb

works
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Sun, 05 Jun 2022 22:57:31 +0100
parents f67f9ea191b7
children 7d4da4e72d37
files sendpwf.py
diffstat 1 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sendpwf.py	Sun Jun 05 22:57:31 2022 +0100
@@ -0,0 +1,42 @@
+#!/usr/bin/python3
+"""Send my encrypted pw files to joanna, james and emma"""
+from email.message import EmailMessage
+from email.policy import SMTP
+
+import smtplib, sys
+
+if sys.argv[1]=='-d':
+  sys.argv.pop(1)
+  debug=sys.argv.pop(1)
+else:
+  debug=None
+
+date=sys.argv[1]
+
+
+m=EmailMessage(policy=SMTP)
+m['From']='ht@home.hst.name'
+m['To']="Emma JD Boland <emma.jd.boland@gmail.com>, James Thompson <jamesejthompson@gmail.com>, Joanna Thompson <joannat.is@gmail.com>"
+m['Cc']="Catharine Ward Thompson <catharine122@gmail.com>"
+m['Subject']='Monthly distro'
+m.set_content("""As promised
+
+ht
+""")
+for f in ['password_intro_%s.txt.gpg','passwords_%s.gpg']:
+  ff=f%date
+  with open(ff,'rb') as fp:
+    data=fp.read()
+    m.add_attachment(data,
+                     maintype='application',
+                     subtype='octet-stream',
+                     disposition='attachment',
+                     filename=ff)
+
+if debug:
+  with open(debug,'wb') as dbf:
+    dbf.write(m.as_bytes())
+else:
+  server=smtplib.SMTP('localhost')
+  server.send_message(m)
+  server.close()