Extract and work with your email using the command line with this plugin for chronicle-etl.
# Install chronicle-etl and this plugin
$ gem install chronicle-etl
$ chronicle-etl plugins:install email
For Gmail accounts, you can create an app password; your email address is your username.
# Save username and password
$ chronicle-etl secrets:set imap username foo@gmail.com
$ chronicle-etl secrets:set imap password APPPASSWORD
# Then, retrieve your email from the last five days
$ chronicle-etl --extractor email:imap --schema chronicle --since 5d
# If you don't want to save your credentials as a secret, you can just pass
# them to the extractor directly
$ chronicle-etl --extractor email:imap --schema chronicle --since 5d --loader json \
--extractor-opts username:foo@gmail.com --password:APPPASSWORD
The MBOX format is used to archive an email mailbox. Google Takeout exports emails from gmail in this format.
# Retrieve the subject lines of all emails in test.mbox
$ chronicle-etl --extractor email:mbox --input ~/Downloads/inbox.mbox --fields subject
Extractor for importing recent emails from an IMAP server.
since
: Retrieve emails since this dateuntil
: Retrieve emails until this dateusername
password
host
: (default: imap.gmail.com)port
: (default: 993) Use 143 for unencrypted connectionsmailbox
: (default: "[Gmail]/All Mail")search_query
: When using Gmail, you can pass in a search query (from:foo has:attachment
) to filter messages by
For accessing Gmail, you can create a one-time app password. Your email address is your username.
Extractor for importing emails from an MBOX file
input
: A path to an .mbox file
Transform an email (in the form of a string) into Chronicle Schema
body_as_markdown
: (default: false) Whether to convert the email body into markdownremove_signature
: (default: true) Whether to attempt to strip out the email signature (using theemail_reply_parser
gem)