Ticket #3448: core_mail_help-v2.diff

File core_mail_help-v2.diff, 2.9 KB (added by Per Jonsson <poj@…>, 9 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:
  • docs/email.txt

     
    3434``django.core.mail.send_mail()``. Here's its definition::
    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
    4141are required.
     
    6565Here's the definition::
    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::
    7171
Back to Top