Advertisement
Fhernd

conexion-imap.py

Feb 9th, 2018
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import imaplib, getpass
  2.  
  3. # Conexión:
  4. servidor_imap = imaplib.IMAP4('proveedorimap.com')
  5. servidor_imap.login(getpass.getuser(), getpass.getpass())
  6.  
  7. # Obtener lista de emails:
  8. tipo, datos = servidor_imap.search(None, 'ALL')
  9.  
  10. # ID de email a recuperar:
  11. id_email = 123456
  12.  
  13. # Obtener emails:
  14. mensaje = servidor_imap.fetch(id_email, '(RFC822)')
  15.  
  16. # Eliminar un email:
  17. servidor_imap.store(id_email, '+FLAGS', '\\Deleted')
  18. servidor_imap.expunge()
  19.  
  20. # Cierre de conexión con el servidor:
  21. servidor_imap.close()
  22. servidor_imap.logout()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement