Django

Code

Changeset 4574

Show
Ignore:
Timestamp:
02/25/07 10:29:09 (2 years ago)
Author:
jacob
Message:

Fixed #3488: send_mail no longer uses settings in function default arguments. Thanks to Per Jonsson for the patch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/mail.py

    r4570 r4574  
    3535        MIMEText.__setitem__(self, name, val) 
    3636 
    37 def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD): 
     37def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None): 
    3838    """ 
    3939    Easy wrapper for sending a single message to a recipient list. All members 
    4040    of the recipient list will see the other recipients in the 'To' field. 
     41 
     42    If auth_user is None, the EMAIL_HOST_USER setting is used. 
     43    If auth_password is None, the EMAIL_HOST_PASSWORD setting is used. 
    4144    """ 
     45    if auth_user is None: 
     46        auth_user = settings.EMAIL_HOST_USER 
     47    if auth_password is None: 
     48        auth_password = settings.EMAIL_HOST_PASSWORD 
    4249    return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently, auth_user, auth_password) 
    4350 
    44 def send_mass_mail(datatuple, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD): 
     51def send_mass_mail(datatuple, fail_silently=False, auth_user=None, auth_password=None): 
    4552    """ 
    4653    Given a datatuple of (subject, message, from_email, recipient_list), sends 
     
    4956    If from_email is None, the DEFAULT_FROM_EMAIL setting is used. 
    5057    If auth_user and auth_password are set, they're used to log in. 
     58    If auth_user is None, the EMAIL_HOST_USER setting is used. 
     59    If auth_password is None, the EMAIL_HOST_PASSWORD setting is used. 
    5160    """ 
     61    if auth_user is None: 
     62        auth_user = settings.EMAIL_HOST_USER 
     63    if auth_password is None: 
     64        auth_password = settings.EMAIL_HOST_PASSWORD 
    5265    try: 
    5366        server = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT) 
  • django/trunk/docs/email.txt

    r4420 r4574  
    3535 
    3636    send_mail(subject, message, from_email, recipient_list, 
    37         fail_silently=False, auth_user=EMAIL_HOST_USER
    38         auth_password=EMAIL_HOST_PASSWORD
     37        fail_silently=False, auth_user=None
     38        auth_password=None
    3939 
    4040The ``subject``, ``message``, ``from_email`` and ``recipient_list`` parameters 
     
    6666 
    6767    send_mass_mail(datatuple, fail_silently=False, 
    68         auth_user=EMAIL_HOST_USER, auth_password=EMAIL_HOST_PASSWORD): 
     68        auth_user=None, auth_password=None): 
    6969 
    7070``datatuple`` is a tuple in which each element is in this format::