155
155
extension, **kwargs)
157
157
def _compose(self, prompt, to, subject, attach_path, mime_subtype,
158
extension, body=None):
158
extension, body=None, from_=None):
159
159
"""Invoke a mail client as a commandline process.
161
161
Overridden by MAPIClient.
166
166
"text", but the precise subtype can be specified here
167
167
:param extension: A file extension (including period) associated with
168
168
the attachment type.
169
:param body: Optional body text.
170
:param from_: Optional From: header.
170
172
for name in self._get_client_commands():
171
173
cmdline = [self._encode_path(name, 'executable')]
331
335
class Claws(ExternalMailClient):
332
336
"""Claws mail client."""
334
340
_client_commands = ['claws-mail']
336
def _get_compose_commandline(self, to, subject, attach_path):
342
def _get_compose_commandline(self, to, subject, attach_path, body=None,
337
344
"""See ExternalMailClient._get_compose_commandline"""
338
compose_url = ['mailto:']
340
compose_url.append(self._encode_safe(to))
341
compose_url.append('?')
346
if from_ is not None:
347
compose_url.append('from=' + urllib.quote(from_))
342
348
if subject is not None:
343
349
# Don't use urllib.quote_plus because Claws doesn't seem
344
350
# to recognise spaces encoded as "+".
345
351
compose_url.append(
346
'subject=%s' % urllib.quote(self._encode_safe(subject)))
352
'subject=' + urllib.quote(self._encode_safe(subject)))
355
'body=' + urllib.quote(self._encode_safe(body)))
356
# to must be supplied for the claws-mail --compose syntax to work.
358
raise errors.NoMailAddressSpecified()
359
compose_url = 'mailto:%s?%s' % (
360
self._encode_safe(to), '&'.join(compose_url))
347
361
# Collect command-line options.
348
message_options = ['--compose', ''.join(compose_url)]
362
message_options = ['--compose', compose_url]
349
363
if attach_path is not None:
350
364
message_options.extend(
351
365
['--attach', self._encode_path(attach_path, 'attachment')])
352
366
return message_options
368
def _compose(self, prompt, to, subject, attach_path, mime_subtype,
369
extension, body=None, from_=None):
370
"""See ExternalMailClient._compose"""
372
from_ = self.config.get_user_option('email')
373
super(Claws, self)._compose(prompt, to, subject, attach_path,
374
mime_subtype, extension, body, from_)
353
377
mail_client_registry.register('claws', Claws,
354
378
help=Claws.__doc__)