Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import imaplib, getpass
- # Conexión:
- servidor_imap = imaplib.IMAP4('proveedorimap.com')
- servidor_imap.login(getpass.getuser(), getpass.getpass())
- # Obtener lista de emails:
- tipo, datos = servidor_imap.search(None, 'ALL')
- # ID de email a recuperar:
- id_email = 123456
- # Obtener emails:
- mensaje = servidor_imap.fetch(id_email, '(RFC822)')
- # Eliminar un email:
- servidor_imap.store(id_email, '+FLAGS', '\\Deleted')
- servidor_imap.expunge()
- # Cierre de conexión con el servidor:
- servidor_imap.close()
- servidor_imap.logout()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement