Ciao,
http://www.roberto.foglietta.name/home/index.php?mod=01_Linux/02_Documenti/06_Retrieve_email_addresses_from_a_mailbox.txt