I'm using this code to login to my gmail account and retrieve text from an email from steampowered.
else:
g = gmail.login(emailAddress, emailPassword)
# Check for emails until we get Steam Guard code
for i in range(0, 3):
mails = g.inbox().mail(sender="noreply@steampowered.com", unread=True)
if mails:
mail = mails[-1]
mail.fetch()
#print re.findall(r"you'll need to complete the process: ([A-Z0-9]{5})", mail.body)
guardCode = re.findall(r"you'll need to complete the process: ([A-Z0-9]{5})", mail.body)[0]
mail.read()
mail.delete()
g.logout()
return guardCode
else:
time.sleep(3)
I get a
IndexError: List Index out of Range
At this line:
guardCode = re.findall(r"you'll need to complete the process: ([A-Z0-9]{5})", mail.body)[0]
This is because
re.findall(r"you'll need to complete the process: ([A-Z0-9]{5})", mail.body)
Returns
[]
So the list is empty. Why is it empty?
This is the format of the email:
Are you logging into Steam using a new browser or Steam app? Here’s the Steam Guard code you’ll need to complete the process: XXXXX <---- I need this
EDIT: Gmail is a custom python module from here. EDIT #2: Here's a better representation of the email:
Dear XXX,
Are you logging into Steam using a new browser or Steam app? Here's the Steam Guard code you'll need to complete the process:
XXXXX
If you haven’t recently tried to login to Steam from the device located at XXXX (US), someone else may be trying to access your account. You can view more info about this login attempt online.
If you suspect someone else may be attempting to access your account, please either: