I want to make a script that sends my homework to my mail every now and then, but they sending a mail part isn't working. I have looked at tutorials, but I still get a mistake when i write
msg = MIMEMultipart()
Is there something wrong with that?
(I use gmail)
for name, email in zip(names, emails):
print("Writing the mail")
msg = MIMEMultipart()
# add in the actual person name to the message template
message = message_template.substitute(PERSON_NAME=name.title())
# setup the parameters of the message
msg['From']=Myaddress
msg['To']=email
msg['Subject']="Homework"
# add in the message body
msg.attach(MIMEText(message, 'plain'))
# send the message via the server set up earlier.
s.send_message(msg)
print("Mail sent")
del msg
btw I have multiple mails to send it to. And yes I imported these:
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText