~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mail_client.py

  • Committer: Aaron Bentley
  • Date: 2007-08-09 20:30:00 UTC
  • mto: (2681.5.3 bzr-mail)
  • mto: This revision was merged to the branch mainline in revision 2736.
  • Revision ID: abentley@panoramicfeedback.com-20070809203000-939mwp9uv19snzme
Add support for mail-from-editor

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import subprocess
19
19
import tempfile
20
20
 
21
 
from bzrlib import urlutils
 
21
from bzrlib import (
 
22
    email_message,
 
23
    errors,
 
24
    msgeditor,
 
25
    urlutils,
 
26
    )
22
27
 
23
28
 
24
29
class MailClient(object):
25
30
 
 
31
    def __init__(self, config):
 
32
        self.config = config
 
33
 
26
34
    def compose(self, to, subject, attachment):
27
35
        raise NotImplementedError
28
36
 
29
37
 
30
38
class Editor(MailClient):
31
39
 
32
 
    pass
 
40
    def compose(self, to, subject, attachment):
 
41
        info = ("Please describe these changes:\n\nTo: %s\nSubject: %s\n\n%s"
 
42
                % (to, subject, attachment))
 
43
        body = msgeditor.edit_commit_message(info)
 
44
        if body == '':
 
45
            raise errors.NoMessageSupplied()
 
46
        email_message.EmailMessage.send(self.config,
 
47
                                        self.config.username(),
 
48
                                        to,
 
49
                                        subject,
 
50
                                        body,
 
51
                                        attachment,
 
52
                                        attachment_mime_subtype='x-patch')
33
53
 
34
54
 
35
55
class Thunderbird(MailClient):