1

I'm trying to create a python script that helps me to login into my gmail account when run. I took a quick look at the gmail login page and it was like 2000 lines. Most of it was css and some script. What i want is the script to contain my login details and send them when ran.

5
  • 2
    The problem here is that your browser is being sent a session cookie that will authenticate it once you've entered the correct credentials. Even if you managed to write a python script, you'd have to inject that cookie into your browser to authenticate yourself there too. Commented Sep 3, 2013 at 9:43
  • Tnx for the reply. I dont need to authenticate myself in the browser. I dont have the need for a browser at this point. I just want to check wether the details i sent are correct. Is that possible? Commented Sep 3, 2013 at 9:50
  • 1
    Check out the form, pick the action and method attributes and fill the input fields manually, should be doable I guess... Commented Sep 3, 2013 at 10:03
  • What do you want to do exactly? Login your usual browser through a script? Test that login/pwd are ok? Connect to gmail and programmatically do stuff with your emails? Commented Sep 3, 2013 at 10:40
  • @lajarre: I want to confirm that the login details are correct. That is the part that interests me the most for now Commented Sep 3, 2013 at 18:53

1 Answer 1

2
import smtplib
# Set connection. This has to be using TLS
connection = smtplib.SMTP('smtp.gmail.com', 587)
# Say hello, god knows why
connection.ehlo()
# Start TLS session
connection.starttls()
# Try to login with email/pwd
connection.login('[email protected]', 'mypwd')
# Close it
connection.close()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.