# HG changeset patch # User Henry S. Thompson # Date 1654466251 -3600 # Node ID 737cd0fd5adbd6e29772c2eb1e600ba426d5fc87 # Parent f67f9ea191b7769866803cad20b576ac31fa3b88 works diff -r f67f9ea191b7 -r 737cd0fd5adb sendpwf.py --- /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 , James Thompson , Joanna Thompson " +m['Cc']="Catharine Ward Thompson " +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()