gmail_extract_emails.pl - Extract email addresses from GMail


This script extracts email addresses out of gmail messages (From, To, and CC are parsed). Typical usage: importing them to the address book.

./gmail_extract_emails.pl \
       --username=[user] --password=[password] \
       --csv=gmail.csv \

In case you are not sure about folder names, try:

./gmail_extract_emails.pl \
       --username=[user] --password=[password] \


Required parameters:

--login         GMail username (either "SomeBody@gmail.com", or "SomeBody")
--password      GMail password

Optional parameters:

--folder        GMail folder to scan (default INBOX)
--csv           Name of .csv file to create (if missing, prints on standard output)
--host          IMAP hostname  (default imap.gmail.com)
--port          IMAP port      (default 993)
--verbose       Print some diagnostic messages
--list-folders  Instead of running normally, list IMAP folders on the server
                (use if you are not sure what to give as --folder)

Note that using --folder='[Gmail]/Sent Mail' grabs addresses you sent email to and --folder='[Gmail]/All Mail' processes archived email.

Options --host and --port can be useful if you use port mapping or tunelling, or just want to use IMAP server different than GMail.