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
b03d5002
Kaydet (Commit)
b03d5002
authored
Ara 09, 2017
tarafından
Jon Dufresne
Kaydeden (comit)
Tim Graham
Ara 30, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28971 -- Made EmailMessage.message() set Cc from headers dict if it exists.
üst
63349394
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
message.py
django/core/mail/message.py
+14
-4
tests.py
tests/mail/tests.py
+7
-0
No files found.
django/core/mail/message.py
Dosyayı görüntüle @
b03d5002
...
...
@@ -255,10 +255,8 @@ class EmailMessage:
msg
[
'Subject'
]
=
self
.
subject
msg
[
'From'
]
=
self
.
extra_headers
.
get
(
'From'
,
self
.
from_email
)
msg
[
'To'
]
=
self
.
extra_headers
.
get
(
'To'
,
', '
.
join
(
map
(
str
,
self
.
to
)))
if
self
.
cc
:
msg
[
'Cc'
]
=
', '
.
join
(
str
(
cc
)
for
cc
in
self
.
cc
)
if
self
.
reply_to
:
msg
[
'Reply-To'
]
=
self
.
extra_headers
.
get
(
'Reply-To'
,
', '
.
join
(
str
(
r
)
for
r
in
self
.
reply_to
))
self
.
_set_list_header_if_not_empty
(
msg
,
'Cc'
,
self
.
cc
)
self
.
_set_list_header_if_not_empty
(
msg
,
'Reply-To'
,
self
.
reply_to
)
# Email header names are case-insensitive (RFC 2045), so we have to
# accommodate that when doing comparisons.
...
...
@@ -408,6 +406,18 @@ class EmailMessage:
filename
=
filename
)
return
attachment
def
_set_list_header_if_not_empty
(
self
,
msg
,
header
,
values
):
"""
Set msg's header, either from self.extra_headers, if present, or from
the values argument.
"""
if
values
:
try
:
value
=
self
.
extra_headers
[
header
]
except
KeyError
:
value
=
', '
.
join
(
str
(
v
)
for
v
in
values
)
msg
[
header
]
=
value
class
EmailMultiAlternatives
(
EmailMessage
):
"""
...
...
tests/mail/tests.py
Dosyayı görüntüle @
b03d5002
...
...
@@ -132,6 +132,13 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
[
'to@example.com'
,
'other@example.com'
,
'cc@example.com'
,
'cc.other@example.com'
,
'bcc@example.com'
]
)
def
test_cc_headers
(
self
):
message
=
EmailMessage
(
'Subject'
,
'Content'
,
'bounce@example.com'
,
[
'to@example.com'
],
cc
=
[
'foo@example.com'
],
headers
=
{
'Cc'
:
'override@example.com'
},
)
.
message
()
self
.
assertEqual
(
message
[
'Cc'
],
'override@example.com'
)
def
test_cc_in_headers_only
(
self
):
message
=
EmailMessage
(
'Subject'
,
'Content'
,
'bounce@example.com'
,
[
'to@example.com'
],
...
...
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