(adsbygoogle = window.adsbygoogle || []).push({});
[HOWTO access to email with Python]
Ok, i use python 2.6.
Let's go..
1. ...
#!/usr/bin/python
# -*- coding: utf-8 -*-
2. import library, "poplib".
This is the lib for access a server pop3 of Hotmail.
Is very simple to use..
The poplib is included in python.
import poplib
3. Create "user" and "pass" for de connection with raw_input.
user = raw_input("User: ")
pasi = raw_input("Pass: ")
4. Now, request de server POP3.
server = raw_input("POP3 Server: ")
Ok, i have all informations for my connection.
Personally, my messenger box is Hotmail. I have not tried with gmail.
5. Connect to POP3 with "user", "pass" and "server".
I'm connect to server with SSL connection, more safety.
co = poplib.POP3_SSL(server,995)
co.user(user)
co.pass_(pass)
Ok, now, i'm connected.
I want read the last email in my box.
6. I use "stat()" of poplib.
"stat()" gives me the number of messages in my mail box, and print.
num = (co.stat())
print "-",num,"-"
7. I use "retr()".
"retr()" retrieves email, and print.
iffl = raw_input("Numéro du message: ")
awe = (co.retr(iffl))
print "-",awe,"-"
8. Close the connection !
co.quit()