Skip to content

Commit a4e209a

Browse files
authored
Merge pull request #83 from joehybird/master
Fix unclosed file warning issue.
2 parents 63559f9 + b2e9b98 commit a4e209a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mail_factory/messages.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ def attach_related_file(self, path, mimetype=None, filename=None):
4646
"""Attaches a file from the filesystem."""
4747
if not filename:
4848
filename = basename(path)
49-
content = open(path, 'rb').read()
49+
50+
with open(path, 'rb') as fd:
51+
content = fd.read()
52+
5053
self.attach_related(filename, content, mimetype)
5154

5255
def _create_message(self, msg):

0 commit comments

Comments
 (0)