IMAP + Steampipe
IMAP is a protocol for email access and management.
Steampipe is an open-source zero-ETL engine to instantly query cloud APIs using SQL.
List messages from your inbox:
select timestamp, from_email, subjectfrom imap_message;
+---------------------+---------------------------+---------------------+| timestamp | from_email | subject |+---------------------+---------------------------+---------------------+| 2021-06-04 10:04:09 | michael@dundermifflin.com | FW: Joke || 2021-09-20 10:10:01 | dwight@dundermifflin.com | Where's my stapler? || 2021-09-21 10:13:01 | pam@dundermifflin.com | Tonight... |+---------------------+---------------------------+---------------------+
Documentation
Get started
Install
Download and install the latest IMAP plugin:
steampipe plugin install imap
Configuration
Installing the latest imap plugin will create a config file (~/.steampipe/config/imap.spc
) with a single connection named imap
.
Here is an example configuration for Gmail, which requires allowing your user to use less secure apps.
connection "imap" { plugin = "imap" host = "imap.gmail.com" port = 993 login = "michael@dundermifflin.com" password = "Great Scott!"}
host
- Hostname of the IMAP server. Required. Can also be set with theIMAP_HOST
environment variable.login
- Login name, usually the email address. Required. Can also be set with theIMAP_LOGIN
environment variable.password
- Password. Required. Can also be set with theIMAP_PASSWORD
environment variable.port
- Port to connect on the host, usually 143 for IMAP and 993 for IMAPS. Valid values are 143, 993, or a value between 1024 and 65535. Default 993. Can also be set with theIMAP_PORT
environment variable.tls_enabled
- If true, use TLS to connecto the host. Default true.insecure_skip_verify
- If true, skip certificate verification. Default false.mailbox
- The mailbox to query for messages if not specifically given in the query. Default is INBOX.
By default, variables in the configuration file will take precedence over any configured environment variables.
Postgres FDW
This plugin is available as a native Postgres FDW. Unlike Steampipe CLI, which ships with an embedded Postgres server instance, the Postgres FDW can be installed in any supported Postgres database version.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_postgres_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/postgres.sh)" -- imap
The installer will prompt you for the plugin name and version, download and install the appropriate files for your OS, system architecture, and Postgres version.
To configure the Postgres FDW, you will create an extension, foreign server, and schema and import the foreign schema.
CREATE EXTENSION IF NOT EXISTS steampipe_postgres_imap;CREATE SERVER steampipe_imap FOREIGN DATA WRAPPER steampipe_postgres_imap OPTIONS (config '<your_config>');CREATE SCHEMA imap;IMPORT FOREIGN SCHEMA imap FROM SERVER steampipe_imap INTO imap;
SQLite Extension
This plugin is available as a SQLite Extension, making the tables available as SQLite virtual tables.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_sqlite_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/sqlite.sh)" -- imap
The installer will prompt you for the plugin name, version, and destination directory. It will then determine the OS and system architecture, and it will download and install the appropriate package.
To configure the SQLite extension, load the extension module and then run the steampipe_configure_imap
function to configure it with plugin-specific options.
$ sqlite3sqlite> .load ./steampipe_sqlite_extension_imap.sosqlite> select steampipe_configure_imap('<your_config>');
Export
This plugin is available as a standalone Export CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- imap
You can pass the configuration to the command with the --config
argument:
steampipe_export_imap --config '<your_config>' <table_name>