mirror of https://github.com/fail2ban/fail2ban
construct smtp.py email wrap long lines
RFC 5322 2.1.1 requires <=998 chars per line. If matches are included, and are very long lines, the email will be rejected. Constructing the mail as a message instead of a subpart (mimetext) fixes thispull/4006/head
parent
f7aaaf50b8
commit
a5d7127109
|
@ -19,7 +19,8 @@
|
|||
|
||||
import socket
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
import email.policy
|
||||
from email.message import EmailMessage
|
||||
from email.utils import formatdate, formataddr
|
||||
|
||||
from fail2ban.server.actions import ActionBase, CallingMap
|
||||
|
@ -151,7 +152,8 @@ class SMTPAction(ActionBase):
|
|||
See Python `smtplib` for full list of other possible
|
||||
exceptions.
|
||||
"""
|
||||
msg = MIMEText(text)
|
||||
msg = EmailMessage(policy=email.policy.SMTP)
|
||||
msg.set_content(text)
|
||||
msg['Subject'] = subject
|
||||
msg['From'] = formataddr((self.fromname, self.fromaddr))
|
||||
msg['To'] = self.toaddr
|
||||
|
|
Loading…
Reference in New Issue