<arg choice="opt">
<option>-R *[,-header1,-header2,-header3,...]:*[,-param1,-param2,-param3,...]</option>
</arg>
+ <arg choice="opt">
+ <option>--set-header header:value</option>
+ </arg>
<arg choice="opt">
<option>-beit mask</option>
</arg>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>--set-header header:value</term>
+ <listitem>
+ <para>
+ The program sets or changes value for the header to the given value
+ (only at the top-level message).
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>-b mask</term>
<listitem>
def usage(code=0, errormsg=''):
version(0)
sys.stdout.write("""\
-Usage: %s [-h|--help] [-V|--version] [-cCDP] [-H|--host=hostname] [-f charset] [-d header1[,h2,...]|*[,-h1,...]] [-p header1[,h2,h3,...]:param1[,p2,p3,...]] [-r header1[,h2,...]|*[,-h1,...]] [-R header1[,h2,h3,...]:param1[,p2,p3,...]] [-beit mask] [-o output_file] [input_file [output_file]]
+ Usage: %s [-h|--help] [-V|--version] [-cCDP] [-H|--host=hostname] [-f charset] [-d header1[,h2,...]|*[,-h1,...]] [-p header1[,h2,h3,...]:param1[,p2,p3,...]] [-r header1[,h2,...]|*[,-h1,...]] [-R header1[,h2,h3,...]:param1[,p2,p3,...]] [--set-header header:value] [-beit mask] [-o output_file] [input_file [output_file]]
""" % me)
if errormsg:
sys.stderr.write(errormsg + '\n')
# A list of headers parameters to remove
remove_headers_params = []
+ # A list of header/value pairs to set
+ set_header_value = []
+ # A list of header/parameter/value triples to set
+ #set_header_param = []
+
totext_mask = [] # A list of content-types to decode
binary_mask = [] # A list to pass through
ignore_mask = [] # Ignore (skip, do not decode and do not include into output)
try:
options, arguments = getopt(sys.argv[1:],
'hVcCDPH:f:d:p:r:R:b:e:i:t:o:',
- ['help', 'version', 'host='])
+ ['help', 'version', 'host=', 'set-header='])
except GetoptError:
usage(1)
gopts.remove_headers.append(value)
elif option == '-R':
gopts.remove_headers_params.append(value.split(':', 1))
+ elif option == '--set-header':
+ gopts.set_header_value.append(value.split(':', 1))
elif option == '-t':
gopts.totext_mask.append(value)
elif option == '-b':
gopts.outfile = outfile
output = outfile.write
+ msg = email.message_from_file(infile)
+
+ for header, value in gopts.set_header_value:
+ msg[header] = value
+
try:
- decode_message(email.message_from_file(infile))
+ decode_message(msg)
finally:
infile.close()
outfile.close()
--- /dev/null
+From test Sat Feb 1 00:00:00 2014
+Return-Path: <bbb@zzz.org>
+Delivered-To: bbb@zzz.org
+Received: by mail.zzz.org (Postfix, from userid 889)
+ id 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT)
+Content-Transfer-Encoding: 7bit
+Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
+From: bbb@ddd.com (John X. Doe)
+To: bbb@zzz.org
+Subject: This is a test message
+Date: Fri, 4 May 2001 14:05:44 -0400
+X-Test: set
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+X-MIME-Autoconverted: from us-ascii to utf-8 by test id mimedecode.py
+
+
+Hi,
+
+Do you like this message?
+
+-Me