-def __send_message(smtpserver, from_addr, to_addr_list, msg,
- smtpuser, smtppassword, use_tls):
+def __send_message_git(msg, options):
+ """Send the message using git send-email
+ """
+ from subprocess import call
+ from tempfile import mkstemp
+
+ cmd = ["git", "send-email", "--from=%s" % msg['From']]
+ cmd.append("--quiet")
+ cmd.append("--suppress-cc=self")
+ if not options.auto:
+ cmd.append("--suppress-cc=body")
+ if options.in_reply_to:
+ cmd.extend(["--in-reply-to", options.in_reply_to])
+ if options.no_thread:
+ cmd.append("--no-thread")
+
+ # We only support To/Cc/Bcc in git send-email for now.
+ for x in ['to', 'cc', 'bcc']:
+ if getattr(options, x):
+ cmd.extend('--%s=%s' % (x, a) for a in getattr(options, x))
+
+ (fd, path) = mkstemp()
+ os.write(fd, msg.as_string(options.mbox))
+ os.close(fd)
+
+ try:
+ try:
+ cmd.append(path)
+ call(cmd)
+ except Exception, err:
+ raise CmdException, str(err)
+ finally:
+ os.unlink(path)
+
+def __send_message(type, tmpl, options, *args):