Ticket #3448: core_mail_help.diff
File core_mail_help.diff, 2.1 KB (added by , 18 years ago) |
---|
-
django/core/mail.py
33 33 val = Header(val, settings.DEFAULT_CHARSET) 34 34 MIMEText.__setitem__(self, name, val) 35 35 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):36 def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None): 37 37 """ 38 38 Easy wrapper for sending a single message to a recipient list. All members 39 39 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. 40 43 """ 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 41 48 return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently, auth_user, auth_password) 42 49 43 def send_mass_mail(datatuple, fail_silently=False, auth_user= settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD):50 def send_mass_mail(datatuple, fail_silently=False, auth_user=None, auth_password=None): 44 51 """ 45 52 Given a datatuple of (subject, message, from_email, recipient_list), sends 46 53 each message to each recipient list. Returns the number of e-mails sent. 47 54 48 55 If from_email is None, the DEFAULT_FROM_EMAIL setting is used. 49 56 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. 50 59 """ 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 51 64 try: 52 65 server = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT) 53 66 if auth_user and auth_password: