'I am having an issue regarding MIMEMultipart

I am trying to send emails through python and when assigning a variable to MIMEMultipart I encounter an error where I get the type error:

TypeError: memoryview: a bytes-like object is required, not 'MIMEMultipart'

I do not know why I'm getting this error, please help! Here is my code:

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

#psutil.Process(pid=28604, name='qengine.exe', status='running', started='10:39:41')

MY_ADDRESS = '[email protected]'
PASSWORD = 'password123'
s = smtplib.SMTP_SSL('smtp.gmail.com', 465)
s.ehlo()
s.login(MY_ADDRESS, PASSWORD)



msg = MIMEMultipart()

msg['From'] = MY_ADDRESS
msg['To'] = '[email protected]'
msg['Subject'] = "This is a test message"

s.send(msg)
del msg

s.quit()
print('Sent!')


Solution 1:[1]

Instead of

s.send(msg)

Use

s.send_message(msg)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 George Ogden