Compare commits
No commits in common. "1521b9d19255df6b116c72c2173e1d894cfe5f03" and "cd9aa73a34f71549941c4165eefb9b15a38bc3a1" have entirely different histories.
1521b9d192
...
cd9aa73a34
1 changed files with 3 additions and 11 deletions
|
@ -7,11 +7,6 @@ Used to distinguish testing emails from production ones."""
|
||||||
from django.core.mail.backends.smtp import EmailBackend as DjangoSMTPBackend
|
from django.core.mail.backends.smtp import EmailBackend as DjangoSMTPBackend
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
def omezovatko_poctu_mailu(maily:list, maximum:int) -> str:
|
|
||||||
if len(maily) <= maximum: return str(maily)
|
|
||||||
# Aspoň zhruba simulujeme tisk pole…
|
|
||||||
return '[' + ", ".join(f"'{mail}'" for mail in maily[:maximum - 1]) + f', … ({len(maily)} e-mailů) ]'
|
|
||||||
|
|
||||||
class PrefixingMailBackend(DjangoSMTPBackend):
|
class PrefixingMailBackend(DjangoSMTPBackend):
|
||||||
# method _send is not probably meant to be monkey_patched, so we patch send_messages instead.
|
# method _send is not probably meant to be monkey_patched, so we patch send_messages instead.
|
||||||
def send_messages(self, messages):
|
def send_messages(self, messages):
|
||||||
|
@ -21,13 +16,10 @@ class PrefixingMailBackend(DjangoSMTPBackend):
|
||||||
|
|
||||||
if message.from_email != settings.SERVER_EMAIL:
|
if message.from_email != settings.SERVER_EMAIL:
|
||||||
message.subject = prefix + ' ' + message.subject
|
message.subject = prefix + ' ' + message.subject
|
||||||
to = omezovatko_poctu_mailu(message.to, 3)
|
|
||||||
cc = omezovatko_poctu_mailu(message.cc, 3)
|
|
||||||
bcc = omezovatko_poctu_mailu(message.bcc, 3)
|
|
||||||
message.body = f"""Bylo by posláno na e-maily:
|
message.body = f"""Bylo by posláno na e-maily:
|
||||||
To: {to}
|
To: {message.to}
|
||||||
Cc: {cc}
|
Cc: {message.cc}
|
||||||
Bcc: {bcc}
|
Bcc: {message.bcc}
|
||||||
"""+ "\n\n" + message.body
|
"""+ "\n\n" + message.body
|
||||||
message.to = settings.TESTOVACI_EMAILOVA_KONFERENCE
|
message.to = settings.TESTOVACI_EMAILOVA_KONFERENCE
|
||||||
message.cc = []
|
message.cc = []
|
||||||
|
|
Loading…
Reference in a new issue