--- title: Email importer keywords: fastai sidebar: home_sidebar nb_path: "nbs/gmailimporter.ipynb" ---
This importers fetches your emails and accounts over IMAP, it uses the python built-in imap client and some convenience functions for easier usage, batching and importing to the pod. This importer requires you to login with your email address and an app password. It is tested on gmail, but should work for other IMAP-servers.
{% include note.html content='The recommended usage for Gmail is to enable two-factor authentication. In this case, make sure you allow SMTP-connections and set an application password (explained in the same link)' %}
pod_client = PodClient.from_local_keys()
def get_gmail_creds():
return read_file(HOME_DIR / '.memri' / 'credentials_gmail.txt').split("\n")[:2]
account = Account(service="gmail_imap")
run = PluginRun("", "gmail_importer.plugin", "GmailImporter")
run.add_edge("account", account)
run.status = RUN_STARTED
pod_client.create(run)
pod_client.create(account)
pod_client.create_edge(run.get_edges("account")[0])
print(pod_client.owner_key)
print(pod_client.database_key)
print("To simulate front-end, run:")
print(f"password_simulator --run_id {run.id}")
pod_client.get(run.id).account[0].secret
!run_plugin --plugin_run_id $run.id --owner_key $pod_client.owner_key --database_key $pod_client.database_key