Skip to content

Commit 16da0d3

Browse files
authored
Refactor email message creation in handlers.py
1 parent b349e4e commit 16da0d3

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Lib/logging/handlers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,13 +1121,13 @@ def emit(self, record):
11211121
if not port:
11221122
port = smtplib.SMTP_PORT
11231123
smtp = smtplib.SMTP(self.mailhost, port, timeout=self.timeout)
1124+
msg = EmailMessage()
1125+
msg['From'] = self.fromaddr
1126+
msg['To'] = ','.join(self.toaddrs)
1127+
msg['Subject'] = self.getSubject(record)
1128+
msg['Date'] = email.utils.localtime()
1129+
msg.set_content(self.format(record))
11241130
try:
1125-
msg = EmailMessage()
1126-
msg['From'] = self.fromaddr
1127-
msg['To'] = ','.join(self.toaddrs)
1128-
msg['Subject'] = self.getSubject(record)
1129-
msg['Date'] = email.utils.localtime()
1130-
msg.set_content(self.format(record))
11311131
if self.username:
11321132
if self.secure is not None:
11331133
import ssl

0 commit comments

Comments
 (0)