~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mail_client.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-09 03:27:18 UTC
  • mfrom: (4416.2.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090609032718-j717ilvc5elzr91r
(mbp) allow passing body as attachment to mutt

Show diffs side-by-side

added added

removed removed

Lines of Context:
257
257
                              help=Evolution.__doc__)
258
258
 
259
259
 
260
 
class Mutt(ExternalMailClient):
 
260
class Mutt(BodyExternalMailClient):
261
261
    """Mutt mail client."""
262
262
 
263
263
    _client_commands = ['mutt']
264
264
 
265
 
    def _get_compose_commandline(self, to, subject, attach_path):
 
265
    def _get_compose_commandline(self, to, subject, attach_path, body=None):
266
266
        """See ExternalMailClient._get_compose_commandline"""
267
267
        message_options = []
268
268
        if subject is not None:
270
270
        if attach_path is not None:
271
271
            message_options.extend(['-a',
272
272
                self._encode_path(attach_path, 'attachment')])
 
273
        if body is not None:
 
274
            # Store the temp file object in self, so that it does not get
 
275
            # garbage collected and delete the file before mutt can read it.
 
276
            self._temp_file = tempfile.NamedTemporaryFile(
 
277
                prefix="mutt-body-", suffix=".txt")
 
278
            self._temp_file.write(body)
 
279
            self._temp_file.flush()
 
280
            message_options.extend(['-i', self._temp_file.name])
273
281
        if to is not None:
274
282
            message_options.extend(['--', self._encode_safe(to)])
275
283
        return message_options