Ticket #3307: only_suppress_recipients.diff
File only_suppress_recipients.diff, 2.8 KB (added by , 18 years ago) |
---|
-
django/core/mail.py
29 29 """ 30 30 return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently, auth_user, auth_password) 31 31 32 def send_mass_mail(datatuple, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD ):32 def send_mass_mail(datatuple, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD, suppress_recipients=False): 33 33 """ 34 34 Given a datatuple of (subject, message, from_email, recipient_list), sends 35 35 each message to each recipient list. Returns the number of e-mails sent. 36 36 37 37 If from_email is None, the DEFAULT_FROM_EMAIL setting is used. 38 38 If auth_user and auth_password are set, they're used to log in. 39 If suppress_recipients is True, the first address in the recipients list 40 will be inserted into the 'To:' field and all other addresses will be 41 inserted into the 'Bcc:' field. 39 42 """ 40 43 try: 41 44 server = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT) … … 53 56 msg = SafeMIMEText(message, 'plain', settings.DEFAULT_CHARSET) 54 57 msg['Subject'] = subject 55 58 msg['From'] = from_email 56 msg['To'] = ', '.join(recipient_list) 59 if suppress_recipients: 60 msg['To'] = recipient_list[0] 61 if len(recipient_list) > 1: 62 msg['Bcc'] = ', '.join(recipient_list[1:]) 63 else: 64 msg['To'] = ', '.join(recipient_list) 57 65 msg['Date'] = rfc822.formatdate() 58 66 try: 59 67 random_bits = str(random.getrandbits(64)) -
docs/email.txt
65 65 Here's the definition:: 66 66 67 67 send_mass_mail(datatuple, fail_silently=False, 68 auth_user=EMAIL_HOST_USER, auth_password=EMAIL_HOST_PASSWORD): 68 auth_user=EMAIL_HOST_USER, auth_password=EMAIL_HOST_PASSWORD, 69 suppress_recipients=False): 69 70 70 71 ``datatuple`` is a tuple in which each element is in this format:: 71 72 … … 76 77 77 78 Each separate element of ``datatuple`` results in a separate e-mail message. 78 79 As in ``send_mail()``, recipients in the same ``recipient_list`` will all see 79 the other addresses in the e-mail messages's "To:" field. 80 the other addresses in the e-mail messages's "To:" field. To suppress all but 81 a single address (useful for newsletters or mailing lists), use 82 ``suppress_recipients=True``; this will use the first address in the "To:" 83 field, and place all other addresses in the "Bcc:" field. 80 84 81 85 send_mass_mail() vs. send_mail() 82 86 --------------------------------