Ticket #6918: mail_patch.diff
File mail_patch.diff, 3.9 KB (added by , 16 years ago) |
---|
-
django/core/mail.py
195 195 encoding = None # None => use settings default 196 196 197 197 def __init__(self, subject='', body='', from_email=None, to=None, bcc=None, 198 connection=None, attachments=None, headers=None ):198 connection=None, attachments=None, headers=None, encoding=None): 199 199 """ 200 200 Initialize a single email message (which can be sent to multiple 201 201 recipients). … … 220 220 self.attachments = attachments or [] 221 221 self.extra_headers = headers or {} 222 222 self.connection = connection 223 self.encoding = encoding 223 224 224 225 def get_connection(self, fail_silently=False): 225 226 if not self.connection: … … 318 319 self.attach(content=content, mimetype=mimetype) 319 320 320 321 def send_mail(subject, message, from_email, recipient_list, 321 fail_silently=False, auth_user=None, auth_password=None): 322 fail_silently=False, auth_user=None, auth_password=None, 323 encoding=None): 322 324 """ 323 325 Easy wrapper for sending a single message to a recipient list. All members 324 326 of the recipient list will see the other recipients in the 'To' field. 325 327 326 328 If auth_user is None, the EMAIL_HOST_USER setting is used. 327 329 If auth_password is None, the EMAIL_HOST_PASSWORD setting is used. 330 If encoding is None, the DEFAULT_CHARSET setting is used. 328 331 329 332 Note: The API for this method is frozen. New code wanting to extend the 330 333 functionality should use the EmailMessage class directly. … … 332 335 connection = SMTPConnection(username=auth_user, password=auth_password, 333 336 fail_silently=fail_silently) 334 337 return EmailMessage(subject, message, from_email, recipient_list, 335 connection=connection ).send()338 connection=connection, encoding=encoding).send() 336 339 337 340 def send_mass_mail(datatuple, fail_silently=False, auth_user=None, 338 auth_password=None ):341 auth_password=None, encoding=encoding): 339 342 """ 340 343 Given a datatuple of (subject, message, from_email, recipient_list), sends 341 344 each message to each recipient list. Returns the number of e-mails sent. … … 344 347 If auth_user and auth_password are set, they're used to log in. 345 348 If auth_user is None, the EMAIL_HOST_USER setting is used. 346 349 If auth_password is None, the EMAIL_HOST_PASSWORD setting is used. 350 If encoding is None, the DEFAULT_CHARSET setting is used. 347 351 348 352 Note: The API for this method is frozen. New code wanting to extend the 349 353 functionality should use the EmailMessage class directly. 350 354 """ 351 355 connection = SMTPConnection(username=auth_user, password=auth_password, 352 356 fail_silently=fail_silently) 353 messages = [EmailMessage(subject, message, sender, recipient )357 messages = [EmailMessage(subject, message, sender, recipient, encoding=encoding) 354 358 for subject, message, sender, recipient in datatuple] 355 359 return connection.send_messages(messages) 356 360 -
docs/email.txt
245 245 caller to ensure header names and values are in the correct format for 246 246 an e-mail message. 247 247 248 * ``encoding``: The encoding of the email. Defaults to DEFAULT_CHARSET 249 setting. 250 248 251 For example:: 249 252 250 253 email = EmailMessage('Hello', 'Body goes here', 'from@example.com', 251 254 ['to1@example.com', 'to2@example.com'], ['bcc@example.com'], 252 headers = {'Reply-To': 'another@example.com'}) 255 headers = {'Reply-To': 'another@example.com'}, 256 encoding = 'utf-8') 253 257 254 258 The class has the following methods: 255 259