Changeset 5144
- Timestamp:
- 05/03/07 08:35:02 (1 year ago)
- Files:
-
- django/trunk/django/conf/global_settings.py (modified) (1 diff)
- django/trunk/django/core/mail.py (modified) (3 diffs)
- django/trunk/docs/email.txt (modified) (2 diffs)
- django/trunk/docs/settings.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/conf/global_settings.py
r5072 r5144 120 120 EMAIL_HOST_USER = '' 121 121 EMAIL_HOST_PASSWORD = '' 122 EMAIL_USE_TLS = False 122 123 123 124 # List of strings representing installed apps. django/trunk/django/core/mail.py
r5143 r5144 71 71 72 72 def __init__(self, host=None, port=None, username=None, password=None, 73 fail_silently=False): 74 if host is None: 75 self.host = settings.EMAIL_HOST 76 if port is None: 77 self.port = settings.EMAIL_PORT 78 if username is None: 79 self.username = settings.EMAIL_HOST_USER 80 if password is None: 81 self.password = settings.EMAIL_HOST_PASSWORD 73 use_tls=None, fail_silently=False): 74 self.host = host or settings.EMAIL_HOST 75 self.port = (port is not None) and port or settings.EMAIL_PORT 76 self.username = username or settings.EMAIL_HOST_USER 77 self.password = password or settings.EMAIL_HOST_PASSWORD 78 self.use_tls = (use_tls is not None) and use_tls or settings.EMAIL_USE_TLS 82 79 self.fail_silently = fail_silently 83 80 self.connection = None … … 93 90 try: 94 91 self.connection = smtplib.SMTP(self.host, self.port) 92 if self.use_tls: 93 self.connection.ehlo() 94 self.connection.starttls() 95 self.connection.ehlo() 95 96 if self.username and self.password: 96 97 self.connection.login(self.username, self.password) … … 105 106 try: 106 107 self.connection.quit() 108 except socket.sslerror: 109 # This happens when calling quit() on a TLS connection 110 # sometimes. 111 self.connection.close() 107 112 except: 108 113 if self.fail_silently: django/trunk/docs/email.txt
r5141 r5144 23 23 Mail will be sent using the SMTP host and port specified in the `EMAIL_HOST`_ 24 24 and `EMAIL_PORT`_ settings. The `EMAIL_HOST_USER`_ and `EMAIL_HOST_PASSWORD`_ 25 settings, if set, will be used to authenticate to the SMTP server. 25 settings, if set, will be used to authenticate to the SMTP server and the 26 `EMAIL_USE_TLS`_ settings will control whether a secure connection is used. 26 27 27 28 .. note:: … … 35 36 .. _EMAIL_HOST_USER: ../settings/#email-host-user 36 37 .. _EMAIL_HOST_PASSWORD: ../settings/#email-host-password 38 .. _EMAIL_USE_TLS: ../settings/#email-use-tls 37 39 38 40 django/trunk/docs/settings.txt
r5129 r5144 428 428 or ``django.core.mail.mail_managers``. You'll probably want to include the 429 429 trailing space. 430 431 EMAIL_USE_TLS 432 ------------- 433 434 Default: ``False`` 435 436 Whether to use a TLS (secure) connection when talking to the SMTP server. 430 437 431 438 FIXTURE_DIRS
