imap integration is observing your IMAP server and reporting the amount of unread emails.
To enable this sensor, add the following lines to your
# Example configuration.yaml entry sensor: - platform: imap server: YOUR_IMAP_SERVER username: YOUR_USERNAME password: YOUR_PASSWORD
The IMAP search to perform on the watched folder.
If you’re going to use Gmail, it’s always good practice to create a App Password.
- Go to your Google Account
- Select Security
- Under “Signing in to Google” select App Passwords
- Sign in to your Account, and create a new App Password for Gmail.
You can now use this as your password for Gmail, in your configuration.
By default, this integration will count unread emails. By configuring the search string, you can count other results, for example:
ALLto count all emails in a folder
SUBJECTto find emails in a folder (see IMAP RFC for all standard options)
Gmail’s IMAP extensions allow raw Gmail searches, like
X-GM-RAW "in: inbox older_than:7d"to show emails older than one week in your inbox. Note that raw Gmail searches will ignore your folder configuration and search all emails in your account!
# Example configuration.yaml entry for gmail sensor: - platform: imap server: imap.gmail.com port: 993 username: YOUR_USERNAME password: YOUR_PASSWORD search: FROM <[email protected]>, SUBJECT <subject here> # Or use X-GM-RAW search-term like this, to find unread emails from the last 7 days in your inbox # search: 'X-GM-RAW "in: inbox newer_than:7d is:unread"' # Example configuration.yaml entry for Office 365 sensor: - platform: imap server: outlook.office365.com port: 993 username: [email protected] password: password search: FROM <[email protected]>, SUBJECT <subject here> charset: US-ASCII