#!/usr/bin/env python
import poplib

from email import parser

Archivosclave = open("palabras_busqueda.txt")

PalabrasClave= Archivosclave.readlines()

pop_conn = poplib.POP3_SSL('popuvhc.univ-valenciennes.fr')
pop_conn.user('febel')
pop_conn.pass_('neo2000')
messages=[]
nbr_mess=len(pop_conn.list()[1])
messages = [pop_conn.retr(i) for i in range(1, len(pop_conn.list()[1]) + 1)]
messages = ["\n".join(mssg[1]) for mssg in messages]
messages = [parser.Parser().parsestr(mssg) for mssg in messages]
pop_conn.quit()
for message in messages:
	for PalabraClave in PalabrasClave:
		if PalabraClave.rstrip() in message['Subject']:
			print message['Subject']

