I am trying to login into my email account through a website and run an action when I get a new email (I can't use IMAP, because it's a paid feature). I use the Requests module.
I looked at the POST request Firefox made when logging in and copied the data. When I submit it and look at the response's content, it says "To access your mail.com mailbox you must enable cookies in your browser."
Can someone tell me what I am doing wrong? I checked the cookies for the Session object and it has cookies.
Here's what I have. Feel free to use the testing account information to login and inspect the POST request in your web browser and test it with Python yourself. Note: check the comments, I had to remove the https:// parts of the address out, because it doesn't let me to post "clickable links" yet, not even in code tags.
I looked at the POST request Firefox made when logging in and copied the data. When I submit it and look at the response's content, it says "To access your mail.com mailbox you must enable cookies in your browser."
Can someone tell me what I am doing wrong? I checked the cookies for the Session object and it has cookies.
Here's what I have. Feel free to use the testing account information to login and inspect the POST request in your web browser and test it with Python yourself. Note: check the comments, I had to remove the https:// parts of the address out, because it doesn't let me to post "clickable links" yet, not even in code tags.
import requests user = "[email protected]" psswd = "fortesting" # had to leave out the https part because it doesn't allow me to post "clickable links" website = "www.mail.com" # same for this as above POST_url = "login.mail.com/login#.1258-header-login1-2" # from the POST request info from Firefox's developer tools params = { "service": "mailint", "uasServiceID": "mc_starter_mailcom", # same as above, had to leave https:// out for the successURL, loginFailedURL and loginErrorURL "successURL": "$(clientName)-$(dataCenter).mail.com/login", "loginFailedURL": "www.mail.com/int/logout/?ls=wd", "loginErrorURL": "www.mail.com/int/logout/?ls=te", "edition": "int", "lang": "en", "usertype": "standard", "username": user, "password": psswd } sess = requests.Session() response = sess.post(POST_url, data=params) print(response.text)