The smtplib.server.sendmail function in python raises UnicodeEncodeError: ‘ascii’ codec can’t encode character

I am trying to edit a text file then send it as email body using a python script but im getting the unicode encoding error. After some research i found the solution as using the method .encode(‘utf-8’) but this doesn’t serve me as the sendmail() method only sends strings

SMTPAuthenticationError when sending mail using gmail and python

when i try to send mail using gmail and python error occurred this type of question are already in this site but doesn’t help to me gmail_user = "<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0a676f4a6d676b636624696567">[email protected]</a>" gmail_pwd = "password" TO = '<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="781e0a111d161c381f15191114561b1715">[email protected]</a>' SUBJECT = "Testing sending using gmail" TEXT = "Testing sending mail using gmail servers" … Read more