diff mailer.py @ 4:2d7c91f89f6b

later ecclerig version
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Mon, 09 Mar 2020 17:38:52 +0000
parents e07789816ca5
children 1cef0e5f5851 b1ec44d254c6
line wrap: on
line diff
--- a/mailer.py	Mon Mar 09 17:35:28 2020 +0000
+++ b/mailer.py	Mon Mar 09 17:38:52 2020 +0000
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 '''Attempt at flexible mailout functionality
-Usage: mailer.py [-n] [-s] [-C cc string] [-c COLSPEC[,COLSPEC]*] [-B bcc string] [-b COLSPEC[,COLSPEC]*] [-S col[,col]*] [-a COLSPEC[,COLSPEC]*] [-p COLPAT]* -SA file[,file]* COLSPEC[,COLSPEC]* subject {addr-file|-} body-file
+Usage: mailer.py [-n] [-s] [-C cc string] [-c COLSPEC[,COLSPEC]*] [-B bcc string] [-b COLSPEC[,COLSPEC]*] [-S col[,col]*] [-a COLSPEC[,COLSPEC]*] [-p COLPAT]* [-SA file[,file]*] [-R reply-to] COLSPEC[,COLSPEC]* subject {addr-file|-} body-file
 
 Sends the body as a message from me with subject to destinations per
 lines in the addr-file selected by COLSPECs (to:) or -c/-b COLSPECs (Cc:/Bcc:)
@@ -17,6 +17,7 @@
 -s for substitute into body
 -S for columns to substitute as such
 -p for augmentation pattern for a column
+-R for replyTo address
 
 COLSPEC is of the form a[:n[:f[:g]]] selects from addr-file, which must be tsv
   a gives the column for an email address
@@ -247,8 +248,11 @@
   msg.attach(atm)
 
 dryrun=False
+replyTo=None
+
 sys.argv.pop(0)
 doSub=False
+
 pats=[]
 someExpand=False
 codec='iso-8859-1'
@@ -318,6 +322,12 @@
       pats.append(sys.argv.pop(0))
     else:
       usage('pat')
+  elif sys.argv[0]=='-R':
+    sys.argv.pop(0)
+    if sys.argv:
+      replyTo=sys.argv.pop(0)
+    else:
+      usage('reply to')
   elif sys.argv[0][0]=='-':
     print sys.argv
     usage()
@@ -406,8 +416,11 @@
   if attCols:
     for att in addrList(addrFields,attCols,True):
       doAtt(msg,att,codec)
+  if replyTo is not None:
+    msg["Reply-To"]=replyTo
   if dryrun:
     print recips
+    print msg.keys()
     print msg.as_string()
     exit()
   print "mailing to %s"%recips