I get AttributeError while sending Email with Python

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.", “…@gmail…”, message_body)
smtp.quit()

sendmail(“test subject”, “test body”)

I however get the below bug: AttributeError: ‘int’ object has no attribute ‘encode’

Not quite sure what’s not working…

If I run that code against my mail server, I can send an email…

(It’s also a very longwinded way of doing it…)