Jul-07-2021, 06:55 PM
(Jul-07-2021, 06:39 PM)Gribouillis Wrote: The documentation ofsmtplib.SMTP.sendmail()
says
Quote:msg may be a string containing characters in the ASCII range, or a byteAs you want to send a string containing characters outside the ASCII range, I suggest that you encode the string manually using another encoding, such as utf8, so try this
string. A string is encoded to bytes using the ascii codec, and lone
\r and \n characters are converted to \r\n characters.
msg = (headers + "\r\n\r\n" + content).encode('utf8') session.sendmail(GMAIL_USERNAME, recipient, msg)
Thanks for your reply.
I edited the ending of my file to this (I hope you meant that).
#Send Email & Exit msg = (headers + "\r\n\r\n" + content).encode('utf8') session.sendmail(GMAIL_USERNAME, recipient, msg) session.quit sender = Emailer() sendTo = receiver emailSubject = "Subject" emailContent = "ÄÖÜ" #Sends an email to the "sendTo" address with the specified "emailSubject" as the subject and "emailConten$ sender.sendmail(sendTo, emailSubject, emailContent)When I try to execute it I get the following error:
File "debug2.py", line 40 msg = (headers + "\r\n\r\n" + content).encode('utf8') ^ TabError: inconsistent use of tabs and spaces in indentationI don't see the error here tbh.