Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #3488: send_mail no longer uses settings in function default ar…

…guments. Thanks to Per Jonsson for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4574 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3468fd01a9a66193aed61f4ddbab09a473d45d17 1 parent dcdaa4a
Jacob Kaplan-Moss jacobian authored
Showing with 18 additions and 5 deletions.
  1. +15 −2 django/core/mail.py
  2. +3 −3 docs/email.txt
17 django/core/mail.py
View
@@ -34,21 +34,34 @@ def __setitem__(self, name, val):
val = Header(val, settings.DEFAULT_CHARSET)
MIMEText.__setitem__(self, name, val)
-def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD):
+def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None):
"""
Easy wrapper for sending a single message to a recipient list. All members
of the recipient list will see the other recipients in the 'To' field.
+
+ If auth_user is None, the EMAIL_HOST_USER setting is used.
+ If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.
"""
+ if auth_user is None:
+ auth_user = settings.EMAIL_HOST_USER
+ if auth_password is None:
+ auth_password = settings.EMAIL_HOST_PASSWORD
return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently, auth_user, auth_password)
-def send_mass_mail(datatuple, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD):
+def send_mass_mail(datatuple, fail_silently=False, auth_user=None, auth_password=None):
"""
Given a datatuple of (subject, message, from_email, recipient_list), sends
each message to each recipient list. Returns the number of e-mails sent.
If from_email is None, the DEFAULT_FROM_EMAIL setting is used.
If auth_user and auth_password are set, they're used to log in.
+ If auth_user is None, the EMAIL_HOST_USER setting is used.
+ If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.
"""
+ if auth_user is None:
+ auth_user = settings.EMAIL_HOST_USER
+ if auth_password is None:
+ auth_password = settings.EMAIL_HOST_PASSWORD
try:
server = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT)
if auth_user and auth_password:
6 docs/email.txt
View
@@ -34,8 +34,8 @@ The simplest way to send e-mail is using the function
``django.core.mail.send_mail()``. Here's its definition::
send_mail(subject, message, from_email, recipient_list,
- fail_silently=False, auth_user=EMAIL_HOST_USER,
- auth_password=EMAIL_HOST_PASSWORD)
+ fail_silently=False, auth_user=None,
+ auth_password=None)
The ``subject``, ``message``, ``from_email`` and ``recipient_list`` parameters
are required.
@@ -65,7 +65,7 @@ send_mass_mail()
Here's the definition::
send_mass_mail(datatuple, fail_silently=False,
- auth_user=EMAIL_HOST_USER, auth_password=EMAIL_HOST_PASSWORD):
+ auth_user=None, auth_password=None):
``datatuple`` is a tuple in which each element is in this format::
Please sign in to comment.
Something went wrong with that request. Please try again.