Ticket #3448: core_mail_help.diff

File core_mail_help.diff, 2.1 KB (added by Per Jonsson <poj@…>, 8 years ago)
  • django/core/mail.py

     
    3333            val = Header(val, settings.DEFAULT_CHARSET)
    3434        MIMEText.__setitem__(self, name, val)
    3535
    36 def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD):
     36def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None):
    3737    """
    3838    Easy wrapper for sending a single message to a recipient list. All members
    3939    of the recipient list will see the other recipients in the 'To' field.
     40
     41    If auth_user is None, the EMAIL_HOST_USER setting is used.
     42    If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.
    4043    """
     44    if auth_user is None:
     45        auth_user=settings.EMAIL_HOST_USER
     46    if auth_password is None:
     47        auth_password=settings.EMAIL_HOST_PASSWORD
    4148    return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently, auth_user, auth_password)
    4249
    43 def send_mass_mail(datatuple, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD):
     50def send_mass_mail(datatuple, fail_silently=False, auth_user=None, auth_password=None):
    4451    """
    4552    Given a datatuple of (subject, message, from_email, recipient_list), sends
    4653    each message to each recipient list. Returns the number of e-mails sent.
    4754
    4855    If from_email is None, the DEFAULT_FROM_EMAIL setting is used.
    4956    If auth_user and auth_password are set, they're used to log in.
     57    If auth_user is None, the EMAIL_HOST_USER setting is used.
     58    If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.
    5059    """
     60    if auth_user is None:
     61        auth_user=settings.EMAIL_HOST_USER
     62    if auth_password is None:
     63        auth_password=settings.EMAIL_HOST_PASSWORD
    5164    try:
    5265        server = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT)
    5366        if auth_user and auth_password:
Back to Top