~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smtp_connection.py

  • Committer: Jonathan Riddell
  • Date: 2011-09-16 10:37:07 UTC
  • mto: This revision was merged to the branch mainline in revision 6144.
  • Revision ID: jriddell@canonical.com-20110916103707-aivba3o9dq42ce7u
add gettext() to BzrCommandError uses

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""A convenience class around smtplib."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
from email import Utils
22
20
import errno
23
21
import smtplib
35
33
    )
36
34
 
37
35
 
38
 
smtp_password = config.Option('smtp_password', default=None,
39
 
        help='''\
40
 
Password to use for authentication to SMTP server.
41
 
''')
42
 
smtp_server = config.Option('smtp_server', default=None,
43
 
        help='''\
44
 
Hostname of the SMTP server to use for sending email.
45
 
''')
46
 
smtp_username = config.Option('smtp_username', default=None,
47
 
        help='''\
48
 
Username to use for authentication to SMTP server.
49
 
''')
50
 
 
51
 
 
52
36
class SMTPConnection(object):
53
37
    """Connect to an SMTP server and send an email.
54
38
 
64
48
        if self._smtp_factory is None:
65
49
            self._smtp_factory = smtplib.SMTP
66
50
        self._config = config
67
 
        self._config_smtp_server = config.get('smtp_server')
 
51
        self._config_smtp_server = config.get_user_option('smtp_server')
68
52
        self._smtp_server = self._config_smtp_server
69
53
        if self._smtp_server is None:
70
54
            self._smtp_server = self._default_smtp_server
71
55
 
72
 
        self._smtp_username = config.get('smtp_username')
73
 
        self._smtp_password = config.get('smtp_password')
 
56
        self._smtp_username = config.get_user_option('smtp_username')
 
57
        self._smtp_password = config.get_user_option('smtp_password')
74
58
 
75
59
        self._connection = None
76
60