~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mail_client.py

  • Committer: Barry Warsaw
  • Date: 2009-06-03 19:40:52 UTC
  • mto: This revision was merged to the branch mainline in revision 4409.
  • Revision ID: barry@python.org-20090603194052-odzlfgw06xrpfxdm
Make Claws mail client work, with bodies and setting the From field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
331
331
class Claws(ExternalMailClient):
332
332
    """Claws mail client."""
333
333
 
 
334
    supports_body = True
 
335
 
334
336
    _client_commands = ['claws-mail']
335
337
 
336
 
    def _get_compose_commandline(self, to, subject, attach_path):
 
338
    def _get_compose_commandline(self, to, subject, attach_path, body=None):
337
339
        """See ExternalMailClient._get_compose_commandline"""
338
 
        compose_url = ['mailto:']
339
 
        if to is not None:
340
 
            compose_url.append(self._encode_safe(to))
341
 
        compose_url.append('?')
 
340
        compose_url = []
 
341
        email = self.config.get_user_option('email')
 
342
        if email is not None:
 
343
            compose_url.append('from=' + urllib.quote(email))
342
344
        if subject is not None:
343
345
            # Don't use urllib.quote_plus because Claws doesn't seem
344
346
            # to recognise spaces encoded as "+".
345
347
            compose_url.append(
346
 
                'subject=%s' % urllib.quote(self._encode_safe(subject)))
 
348
                'subject=' + urllib.quote(self._encode_safe(subject)))
 
349
        if body is not None:
 
350
            compose_url.append(
 
351
                'body=' + urllib.quote(self._encode_safe(body)))
 
352
        # to must be supplied for the claws-mail --compose syntax to work.
 
353
        if to is None:
 
354
            raise errors.NoMailAddressSpecified()
 
355
        compose_url = 'mailto:%s?%s' % (
 
356
            self._encode_safe(to), '&'.join(compose_url))
347
357
        # Collect command-line options.
348
 
        message_options = ['--compose', ''.join(compose_url)]
 
358
        message_options = ['--compose', compose_url]
349
359
        if attach_path is not None:
350
360
            message_options.extend(
351
361
                ['--attach', self._encode_path(attach_path, 'attachment')])