| 1 |
Index: django/core/mail.py |
|---|
| 2 |
=================================================================== |
|---|
| 3 |
--- django/core/mail.py (revision 4908) |
|---|
| 4 |
+++ django/core/mail.py (working copy) |
|---|
| 5 |
@@ -17,14 +17,14 @@ |
|---|
| 6 |
val = Header(val, settings.DEFAULT_CHARSET) |
|---|
| 7 |
MIMEText.__setitem__(self, name, val) |
|---|
| 8 |
|
|---|
| 9 |
-def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD): |
|---|
| 10 |
+def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD, tls=getattr(settings, 'EMAIL_TLS', False)): |
|---|
| 11 |
""" |
|---|
| 12 |
Easy wrapper for sending a single message to a recipient list. All members |
|---|
| 13 |
of the recipient list will see the other recipients in the 'To' field. |
|---|
| 14 |
""" |
|---|
| 15 |
- return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently, auth_user, auth_password) |
|---|
| 16 |
+ return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently, auth_user, auth_password, tls) |
|---|
| 17 |
|
|---|
| 18 |
-def send_mass_mail(datatuple, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD): |
|---|
| 19 |
+def send_mass_mail(datatuple, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD, tls=getattr(settings, 'EMAIL_TLS', False)): |
|---|
| 20 |
""" |
|---|
| 21 |
Given a datatuple of (subject, message, from_email, recipient_list), sends |
|---|
| 22 |
each message to each recipient list. Returns the number of e-mails sent. |
|---|
| 23 |
@@ -34,6 +34,9 @@ |
|---|
| 24 |
""" |
|---|
| 25 |
try: |
|---|
| 26 |
server = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT) |
|---|
| 27 |
+ if tls: |
|---|
| 28 |
+ server.starttls() |
|---|
| 29 |
+ server.ehlo() |
|---|
| 30 |
if auth_user and auth_password: |
|---|
| 31 |
server.login(auth_user, auth_password) |
|---|
| 32 |
except: |
|---|