mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +00:00
[1.2.X] Modified the test_client tests to use the non-deprecated mail API.
Backport of r14187 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14188 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
23ecf3cf6c
commit
3c8bc8c64b
@ -1,6 +1,6 @@
|
|||||||
from xml.dom.minidom import parseString
|
from xml.dom.minidom import parseString
|
||||||
|
|
||||||
from django.core.mail import EmailMessage, SMTPConnection
|
from django.core import mail
|
||||||
from django.template import Context, Template
|
from django.template import Context, Template
|
||||||
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound
|
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound
|
||||||
from django.contrib.auth.decorators import login_required, permission_required
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
@ -189,7 +189,7 @@ def broken_view(request):
|
|||||||
raise KeyError("Oops! Looks like you wrote some bad code.")
|
raise KeyError("Oops! Looks like you wrote some bad code.")
|
||||||
|
|
||||||
def mail_sending_view(request):
|
def mail_sending_view(request):
|
||||||
EmailMessage(
|
mail.EmailMessage(
|
||||||
"Test message",
|
"Test message",
|
||||||
"This is a test email",
|
"This is a test email",
|
||||||
"from@example.com",
|
"from@example.com",
|
||||||
@ -197,18 +197,18 @@ def mail_sending_view(request):
|
|||||||
return HttpResponse("Mail sent")
|
return HttpResponse("Mail sent")
|
||||||
|
|
||||||
def mass_mail_sending_view(request):
|
def mass_mail_sending_view(request):
|
||||||
m1 = EmailMessage(
|
m1 = mail.EmailMessage(
|
||||||
'First Test message',
|
'First Test message',
|
||||||
'This is the first test email',
|
'This is the first test email',
|
||||||
'from@example.com',
|
'from@example.com',
|
||||||
['first@example.com', 'second@example.com'])
|
['first@example.com', 'second@example.com'])
|
||||||
m2 = EmailMessage(
|
m2 = mail.EmailMessage(
|
||||||
'Second Test message',
|
'Second Test message',
|
||||||
'This is the second test email',
|
'This is the second test email',
|
||||||
'from@example.com',
|
'from@example.com',
|
||||||
['second@example.com', 'third@example.com'])
|
['second@example.com', 'third@example.com'])
|
||||||
|
|
||||||
c = SMTPConnection()
|
c = mail.get_connection()
|
||||||
c.send_messages([m1,m2])
|
c.send_messages([m1,m2])
|
||||||
|
|
||||||
return HttpResponse("Mail sent")
|
return HttpResponse("Mail sent")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user