If the template is a multipart MIME message, it sets the charset only to
the payloads. The patch also adds the '--attach' option to 'mail' which uses
the templates/mailattch.tmpl template file.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
format are generated from the template file passed as argument to
'--template' (defaulting to '.git/patchmail.tmpl' or
'~/.stgit/templates/patchmail.tmpl' or
format are generated from the template file passed as argument to
'--template' (defaulting to '.git/patchmail.tmpl' or
'~/.stgit/templates/patchmail.tmpl' or
-'/usr/share/stgit/templates/patchmail.tmpl').
+'/usr/share/stgit/templates/patchmail.tmpl'). A patch can be sent as
+attachment using the --attach option in which case the 'mailattch.tmpl'
+template will be used instead of 'patchmail.tmpl'.
The To/Cc/Bcc addresses can either be added to the template file or
passed via the corresponding command line options. They can be e-mail
The To/Cc/Bcc addresses can either be added to the template file or
passed via the corresponding command line options. They can be e-mail
make_option('--unrelated',
help = 'send patches without sequence numbering',
action = 'store_true'),
make_option('--unrelated',
help = 'send patches without sequence numbering',
action = 'store_true'),
+ make_option('--attach',
+ help = 'send a patch as attachment',
+ action = 'store_true'),
make_option('-v', '--version', metavar = 'VERSION',
help = 'add VERSION to the [PATCH ...] prefix'),
make_option('--prefix', metavar = 'PREFIX',
make_option('-v', '--version', metavar = 'VERSION',
help = 'add VERSION to the [PATCH ...] prefix'),
make_option('--prefix', metavar = 'PREFIX',
to_addr = ', '.join(options.to)
if options.cc:
cc_addr = ', '.join(options.cc + extra_cc)
to_addr = ', '.join(options.to)
if options.cc:
cc_addr = ', '.join(options.cc + extra_cc)
+ cc_addr = ', '.join(options.cc + extra_cc)
elif extra_cc:
cc_addr = ', '.join(extra_cc)
if options.bcc:
elif extra_cc:
cc_addr = ', '.join(extra_cc)
if options.bcc:
msg.replace_header(header, new_val)
# encode the body and set the MIME and encoding headers
msg.replace_header(header, new_val)
# encode the body and set the MIME and encoding headers
- msg.set_charset(charset)
+ if msg.is_multipart():
+ for p in msg.get_payload():
+ p.set_charset(charset)
+ else:
+ msg.set_charset(charset)
def __edit_message(msg):
fname = '.stgitmail.txt'
def __edit_message(msg):
fname = '.stgitmail.txt'
if options.template:
tmpl = file(options.template).read()
else:
if options.template:
tmpl = file(options.template).read()
else:
- tmpl = templates.get_template('patchmail.tmpl')
+ if options.attach:
+ tmpl = templates.get_template('mailattch.tmpl')
+ else:
+ tmpl = templates.get_template('patchmail.tmpl')
if not tmpl:
raise CmdException, 'No e-mail template file found'
if not tmpl:
raise CmdException, 'No e-mail template file found'
--- /dev/null
+From: %(sender)s
+Subject: [%(prefix)sPATCH%(version)s%(number)s] %(shortdescr)s
+Mime-Version: 1.0
+Content-Type: multipart/mixed; boundary=MIMEBOUNDARY
+
+This is a MIME message.
+
+--MIMEBOUNDARY
+Content-Type: text/plain
+Content-Disposition: inline
+
+%(fromauth)s%(longdescr)s
+---
+
+%(diffstat)s
+--MIMEBOUNDARY
+Content-Type: text/plain; name=%(patch)s.patch
+Content-Disposition: attachment; filename=%(patch)s.patch
+
+%(diff)s
+--MIMEBOUNDARY--