import smtplib, ssl
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from secrets import mycred
file=pd.read_excel('emails.xlsx',sheet_name='Sheet1')
contacts=pd.DataFrame(file)
password = mycred()[1]
for i in range(len(contacts)):
name, email, address=contacts.iloc[i]
port = 587 # For SSL
smtp_server = "smtp.mail.com"
msg = MIMEMultipart()
msg['From'] = mycred()[0]
msg['To'] = email
msg['Subject'] = "TEST"
body = "Hey {}, how is it going? I just wanted to confirm your infromationAre you still at{}?" .format(name.split()[0],address)
msg.attach(MIMEText(body, 'plain'))
text = msg.as_string()
context = ssl.create_default_context()
with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
server.login(mycred()[0], password)
server.sendmail(mycred()[0], msg['To'] , text)
print('Sent to: ',name)
print('Done')
This is the code. And the i get this error message when i try to run it. I really don't know how to fix this.
File "c:/Users/rasmu/OneDrive/Dokumenter/VS Projekter/mailtest/emailer.py", line 21
message.attach(MIMEText(body, 'plain'))
^
IndentationError: unexpected indent
PS C:\Users\rasmu\OneDrive\Dokumenter\VS Projekter\mailtest>
How can i fix this?