44
|
1 #!/usr/bin/python3
|
|
2 """Send my encrypted pw files to joanna, james and emma"""
|
|
3 from email.message import EmailMessage
|
|
4 from email.policy import SMTP
|
|
5
|
|
6 import smtplib, sys
|
|
7
|
45
|
8 if len(sys.argv)>0 and sys.argv[1]=='-d':
|
44
|
9 sys.argv.pop(1)
|
|
10 debug=sys.argv.pop(1)
|
|
11 else:
|
|
12 debug=None
|
|
13
|
|
14 date=sys.argv[1]
|
|
15
|
|
16
|
|
17 m=EmailMessage(policy=SMTP)
|
|
18 m['From']='ht@home.hst.name'
|
|
19 m['To']="Emma JD Boland <emma.jd.boland@gmail.com>, James Thompson <jamesejthompson@gmail.com>, Joanna Thompson <joannat.is@gmail.com>"
|
|
20 m['Cc']="Catharine Ward Thompson <catharine122@gmail.com>"
|
|
21 m['Subject']='Monthly distro'
|
|
22 m.set_content("""As promised
|
|
23
|
|
24 ht
|
|
25 """)
|
|
26 for f in ['password_intro_%s.txt.gpg','passwords_%s.gpg']:
|
|
27 ff=f%date
|
|
28 with open(ff,'rb') as fp:
|
|
29 data=fp.read()
|
|
30 m.add_attachment(data,
|
|
31 maintype='application',
|
|
32 subtype='octet-stream',
|
|
33 disposition='attachment',
|
|
34 filename=ff)
|
|
35
|
|
36 if debug:
|
|
37 with open(debug,'wb') as dbf:
|
|
38 dbf.write(m.as_bytes())
|
|
39 else:
|
|
40 server=smtplib.SMTP('localhost')
|
|
41 server.send_message(m)
|
|
42 server.close()
|