Look at this part:
while True:
euser = input("Enter Gmail Username: ")
epass = input("Enter Gmail Password: ")
try:
user.login(euser, epass)
except smtplib.SMTPAuthenticationError:
print ("Invalid Credentials!")
continue
break
When login succeeds, the next statement that is executed is break
, and that throws you back to the beginning of the outer while
loop. You need to move the break
into the try
statement (and you can remove the continue
because you're now at the end of the loop anyway), and outdent the following while
loop so it's on the same level as the previous one:
while True:
euser = input("Enter Gmail Username: ")
epass = input("Enter Gmail Password: ")
try:
user.login(euser, epass)
break
except smtplib.SMTPAuthenticationError:
print ("Invalid Credentials!")
while True:
if end == "true" or end2 == "true": # better use booleans and `if end or end2:`
break
# unnecessary: user.login(euser, epass)
print ("Retrieving Files")