In this section, we present how to connect Email accounts to MindsDB.
By connecting your email account to MindsDB, you can utilize various AI models available within MindsDB to summarize emails, detect spam, or even automate email replies.
Please note that currently you can connect Gmail accounts using this integration.
Connection
This handler was implemented using standard Python libraries: email
, imaplib
, and smtplib
.
The Email handler is initialized with the following required parameters:
email
stores an email address used for authentication.password
stores a password used for authentication.
At the moment, the handler has only been tested with Gmail accounts.
To use the handler on a Gmail account, you must create an app password following this instruction.
Additionally, the following optional parameters can be passed:
smtp_server
used to send emails. Defaults tosmtp.gmail.com
.smtp_port
used to send emails. Defaults to587
.imap_server
used to receive emails. Defaults toimap.gmail.com
.
To connect your email account to MindsDB, use the below CREATE DATABASE
statement:
CREATE DATABASE email_datasource
WITH ENGINE = 'email',
PARAMETERS = {
"email": "youremail@gmail.com",
"password": "yourpassword"
};
It creates a database that comes with the emails
table.
Usage
Now you can query for emails like this:
SELECT *
FROM email_datasource.emails;
And you can apply filters like this:
SELECT id, to, subject, body
FROM email_datasource.emails
WHERE subject = 'MindsDB'
ORDER BY id
LIMIT 5;
Or, write emails like this:
INSERT INTO email_datasource.emails(to, subject, body)
VALUES ("toemail@email.com", "MindsDB", "Hello from MindsDB!");