I’m new to programming and built this code to send an email to someone every week however I’m getting this error for line nine SyntaxError: invalid syntax. Maybe you meant ‘==’ or ‘:=’ instead of ‘=’? (password.py, line 9). it was fine with the code until I put into the brackets to make it so that it would send every week. anyone got any ideas on how I could fix this?
would be greatly appreciated thanks.
1 import smtplib
2 from email.mime.text import MIMEText
3 from email.mime.multipart import MIMEMultipart
4 from email.mime.base import MIMEBase
5 from email import encoders
6 import time
7 while True :
8 {
9 my_email = '[email protected]'
10 my_password = 'password'
11 send_to_email = 'recipient email'
12 subject = 'Open table this week'
13 body = 'email text'
14
15 msg = MIMEMultipart()
16 msg ['From'] = my_email
17 msg ['To'] = send_to_email
18 msg ['Subject'] = subject
19
20 server = smtplib.SMTP('smtp.gmail.com', 587)
21 server.starttls()
22 server.login(my_email, my_password)
23 text = msg.as_string()
24 server.sendmail(my_email, send_to_email, body)
25 server.quit()
26 }
27 time.sleep(60*10080) # this is in seconds, so 60 seconds x 30 mins
I thought it would just be fine being in the brackets but its not.
Connor Smith-Sweeney is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.