~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mail_client.py

  • Committer: Gavin Panella
  • Date: 2009-01-05 17:12:46 UTC
  • mto: This revision was merged to the branch mainline in revision 3927.
  • Revision ID: gavin.panella@canonical.com-20090105171246-eq10vn8lrv80a2ao
Use the --attach option, and don't specify a From: header.

Show diffs side-by-side

added added

removed removed

Lines of Context:
310
310
 
311
311
    def _get_compose_commandline(self, to, subject, attach_path):
312
312
        """See ExternalMailClient._get_compose_commandline"""
313
 
        options = []
 
313
        compose_url = ['mailto:']
 
314
        if to is not None:
 
315
            compose_url.append(self._encode_safe(to))
 
316
        compose_url.append('?')
314
317
        if subject is not None:
315
 
            options.append(
316
 
                ('subject', self._encode_safe(subject)))
 
318
            # Don't use urllib.quote_plus because Claws doesn't seem
 
319
            # to recognise spaces encoded as "+".
 
320
            compose_url.append(
 
321
                'subject=%s' % urllib.quote(self._encode_safe(subject)))
 
322
        # Collect command-line options.
 
323
        message_options = ['--compose', ''.join(compose_url)]
317
324
        if attach_path is not None:
318
 
            options.append(
319
 
                ('attach', self._encode_path(attach_path, 'attachment')))
320
 
        if self.config is not None:
321
 
            username = self.config.username()
322
 
            if username is not None:
323
 
                options.append(
324
 
                    ('from', self._encode_safe(username)))
325
 
        # Doesn't use urllib.urlencode because it uses quote_plus, and
326
 
        # Claws doesn't seem to recognise spaces encoded as "+".
327
 
        option_string = '&'.join(
328
 
            '%s=%s' % (urllib.quote(key), urllib.quote(value))
329
 
            for (key, value) in options)
330
 
        if to is None:
331
 
            to = ''
332
 
        return ['--compose', '%s?%s' % (self._encode_safe(to), option_string)]
 
325
            message_options.extend(
 
326
                ['--attach', self._encode_path(attach_path, 'attachment')])
 
327
        return message_options
333
328
mail_client_registry.register('claws', Claws,
334
329
                              help=Claws.__doc__)
335
330