Opened 17 years ago

Closed 17 years ago

#4086 closed (fixed)

Redundant code in django.core.mail.send_mail()

Reported by: Ilya Semenov <semenov@…> Owned by: Adrian Holovaty
Component: Core (Other) Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

See below, I commented the code which is just redundant and can be safely removed (auth_user/auth_password will anyway be fetched from settings later inside send_mass_mail)

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=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

    # ...skipped the rest

Change History (2)

comment:1 by Gary Wilson <gary.wilson@…>, 17 years ago

Has patch: set
Triage Stage: UnreviewedReady for checkin

yes, I think you are right.

comment:2 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [5041]) Fixed #4086 -- Removed some redundant code points out by Ilya Semenov.

Note: See TracTickets for help on using tickets.
Back to Top