Skip to content

Commit 2d7d4f9

Browse files
committed
Add helper for sending a preformatted message (string containing From:, To:, ..., already)
- Legacy-Id: 2285
1 parent e9f5b41 commit 2d7d4f9

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • branch/iesg-tracker/ietf/utils

branch/iesg-tracker/ietf/utils/mail.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from email.MIMEText import MIMEText
55
from email.MIMEMessage import MIMEMessage
66
from email.MIMEMultipart import MIMEMultipart
7+
from email import message_from_string
78
import smtplib
89
from django.conf import settings
910
from django.core.exceptions import ImproperlyConfigured
@@ -154,3 +155,11 @@ def send_mail_text(request, to, frm, subject, txt, cc=None, extra=None, toUser=N
154155
if bcc:
155156
msg['X-Tracker-Bcc']=bcc
156157
copy_email(msg, copy_to)
158+
159+
def send_mail_preformatted(request, preformatted):
160+
"""Parse preformatted string containing mail with From:, To:, ...,
161+
and send it through the standard IETF mail interface (inserting
162+
extra headers as needed)."""
163+
164+
msg = message_from_string(preformatted.encode("utf-8"))
165+
send_mail_text(request, msg['To'], msg["From"], msg["Subject"], msg.get_payload(), cc=msg["Cc"], bcc=msg["Bcc"])

0 commit comments

Comments
 (0)