I am trying to send an email with Python. But I'm having a bug. This is my code:
import smtplib
def sendmail(subject, body):
smtp = smtplib.SMTP("smtp.gmail.com", 587)
smtp.ehlo()
smtp.starttls()
smtp.login("....@gmail.com", PASSWORD)
message_body = f"Subject:{subject}\n\n{body}"
smtp.sendmail("...@gmail.com", "....@gmail.com", message_body)
smtp.quit()
sendmail("test subject", "test body")
I however get the below bug: AttributeError: 'int' object has no attribute 'encode'