Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
5993b52e
Kaydet (Commit)
5993b52e
authored
Şub 25, 2015
tarafından
medmunds
Kaydeden (comit)
Tim Graham
Mar 13, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24416 -- Added support for lazy email addresses.
üst
d8de9a64
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
message.py
django/core/mail/message.py
+4
-4
tests.py
tests/mail/tests.py
+25
-0
No files found.
django/core/mail/message.py
Dosyayı görüntüle @
5993b52e
...
...
@@ -101,7 +101,7 @@ def forbid_multi_line_headers(name, val, encoding):
def
sanitize_address
(
addr
,
encoding
):
if
isinstance
(
addr
,
six
.
string_types
):
if
not
isinstance
(
addr
,
tuple
):
addr
=
parseaddr
(
force_text
(
addr
))
nm
,
addr
=
addr
nm
=
Header
(
nm
,
encoding
)
.
encode
()
...
...
@@ -262,11 +262,11 @@ class EmailMessage(object):
msg
=
self
.
_create_message
(
msg
)
msg
[
'Subject'
]
=
self
.
subject
msg
[
'From'
]
=
self
.
extra_headers
.
get
(
'From'
,
self
.
from_email
)
msg
[
'To'
]
=
self
.
extra_headers
.
get
(
'To'
,
', '
.
join
(
self
.
to
))
msg
[
'To'
]
=
self
.
extra_headers
.
get
(
'To'
,
', '
.
join
(
map
(
force_text
,
self
.
to
)
))
if
self
.
cc
:
msg
[
'Cc'
]
=
', '
.
join
(
self
.
cc
)
msg
[
'Cc'
]
=
', '
.
join
(
map
(
force_text
,
self
.
cc
)
)
if
self
.
reply_to
:
msg
[
'Reply-To'
]
=
self
.
extra_headers
.
get
(
'Reply-To'
,
', '
.
join
(
self
.
reply_to
))
msg
[
'Reply-To'
]
=
self
.
extra_headers
.
get
(
'Reply-To'
,
', '
.
join
(
map
(
force_text
,
self
.
reply_to
)
))
# Email header names are case-insensitive (RFC 2045), so we have to
# accommodate that when doing comparisons.
...
...
tests/mail/tests.py
Dosyayı görüntüle @
5993b52e
...
...
@@ -665,6 +665,31 @@ class BaseEmailBackendTests(HeadersCheckMixin, object):
self
.
assertEqual
(
message
.
get
(
'from'
),
"tester"
)
self
.
assertEqual
(
message
.
get
(
'to'
),
"django"
)
def
test_lazy_addresses
(
self
):
"""
Email sending should support lazy email addresses (#24416).
"""
_
=
ugettext_lazy
self
.
assertTrue
(
send_mail
(
'Subject'
,
'Content'
,
_
(
'tester'
),
[
_
(
'django'
)]))
message
=
self
.
get_the_message
()
self
.
assertEqual
(
message
.
get
(
'from'
),
'tester'
)
self
.
assertEqual
(
message
.
get
(
'to'
),
'django'
)
self
.
flush_mailbox
()
m
=
EmailMessage
(
'Subject'
,
'Content'
,
_
(
'tester'
),
[
_
(
'to1'
),
_
(
'to2'
)],
cc
=
[
_
(
'cc1'
),
_
(
'cc2'
)],
bcc
=
[
_
(
'bcc'
)],
reply_to
=
[
_
(
'reply'
)],
)
self
.
assertEqual
(
m
.
recipients
(),
[
'to1'
,
'to2'
,
'cc1'
,
'cc2'
,
'bcc'
])
m
.
send
()
message
=
self
.
get_the_message
()
self
.
assertEqual
(
message
.
get
(
'from'
),
'tester'
)
self
.
assertEqual
(
message
.
get
(
'to'
),
'to1, to2'
)
self
.
assertEqual
(
message
.
get
(
'cc'
),
'cc1, cc2'
)
self
.
assertEqual
(
message
.
get
(
'Reply-To'
),
'reply'
)
def
test_close_connection
(
self
):
"""
Test that connection can be closed (even when not explicitly opened)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment