Thanks for the comments, I changed the with statement to this:
with io.open(f'today.txt', "r") as nwf:
text_mail = nwf.read()
I also had to change the smtplib file in my pc's AppData directory, so that a few of the ascii .encode() statements used .encode('utf-8') instead. The changes I made were as follows:
self.putcmd("data")
(code, repl) = self.getreply()
if self.debuglevel > 0:
self._print_debug('data:', (code, repl))
if code != 354:
raise SMTPDataError(code, repl)
else:
if isinstance(msg, str):
msg = _fix_eols(msg).encode('ascii')
to:
self.putcmd("data")
(code, repl) = self.getreply()
if self.debuglevel > 0:
self._print_debug('data:', (code, repl))
if code != 354:
raise SMTPDataError(code, repl)
else:
if isinstance(msg, str):
msg = _fix_eols(msg).encode('utf-8')
If anyone needs to do this for themselves search for 'ascii', change the "msg = _fix_eols(msg).encode('ascii')" statements from above, I believe there are two. I'm not entirely aware of all possible implications for the aforementioned changes, so another fix would likely be better.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…