mirror of https://github.com/django/django.git
Fixed #3007 -- Fixed Python 2.4-ism from [4051] in django/core/mail.py. Also cached the result of socket.getfqdn(). Thanks for the patch, SmileyChris
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4058 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
fdb3b738a8
commit
4b4efced54
|
@ -8,6 +8,8 @@ import socket
|
|||
import time
|
||||
import random
|
||||
|
||||
DNS_NAME = socket.getfqdn() # Cache the hostname
|
||||
|
||||
class BadHeaderError(ValueError):
|
||||
pass
|
||||
|
||||
|
@ -53,7 +55,11 @@ def send_mass_mail(datatuple, fail_silently=False, auth_user=settings.EMAIL_HOST
|
|||
msg['From'] = from_email
|
||||
msg['To'] = ', '.join(recipient_list)
|
||||
msg['Date'] = rfc822.formatdate()
|
||||
msg['Message-ID'] = "<%d.%d@%s>" % (time.time(), random.getrandbits(64), socket.getfqdn())
|
||||
try:
|
||||
random_bits = str(random.getrandbits(64))
|
||||
except AttributeError: # Python 2.3 doesn't have random.getrandbits().
|
||||
random_bits = ''.join([random.choice('1234567890') for i in range(19)])
|
||||
msg['Message-ID'] = "<%d.%d@%s>" % (time.time(), random_bits, DNS_NAME)
|
||||
try:
|
||||
server.sendmail(from_email, recipient_list, msg.as_string())
|
||||
num_sent += 1
|
||||
|
|
Loading…
Reference in New Issue