Skip to main content

Email Forwarding Checker

A small programm that periodically checks if a configured email forwarding for different addresses is working by sending test emails. Purpose is that you will get a notification via MQTT if forwarding stops working and it does not go unnoticed.

How it works

Configure a list of email addresses that should be checked. For those addresses there should be a forwarding configured. Then test emails will be sent periodically to those email adresses via a configurable SMTP server.

Lastly, it will be checked if the test emails arrived at the destination by looking into a configurable IMAP postbox. If the test emails do not arrive there within a specific amount of time, then the forwarding is considered to be not working.

Hot to use it

Install the Python package via pip, install it from source or use the docker image:

docker pull ghcr.io/verybadsoldier/email_forwarding_checker

Docker

Example docker-compose.yml:

version: '3'
services:
  email_forwarding_checker:
    image: ghcr.io/verybadsoldier/email_forwarding_checker:0.2.2
    container_name: email_forwarding_checker
    volumes:
      - ./config.yml:/config.yml
    restart: always
    environment:
      - TZ=Europe/Berlin

Configuration

Example config:

smtp:
  host: smtp.zoho.com
  username: myuser
  password: mypasswd
  sender: checker@check.com

imap:
  host: imap.zoho.com
  username: myimapuser
  password: myimappw

mqtt:
  host: 192.168.2.33
  topic_base: home/email_forwarding_checker

daemon:
  check_interval_hours: 1
  run_now: true  # run once instantly upon startup, then every check_interval_hours hours

email_timeout: 2400  # if the test email does not arrive with this time in seconds, then the forwarding is considered to have failed
repeat_interval: 5  # within email_timeout, check every n seconds for the test email
delete_emails: false  # delete the test emails from the IMAP postbox after arrival
emails:
        - address1@gmail.com
        - address2@gmail.com:3  # optionally suffix :<n> to retry up to n times before marking as failed
        - address3@gmail.com

Healthchecks.io integration

The checker can ping healthchecks.io (or a self-hosted Healthchecks instance) for each monitored address. A start ping is sent before each check and a success or fail ping is sent once the result is known, giving you dead-man's-switch monitoring.

Add the following section to your config:

healthchecks:
  enabled: true
  # Ping URL template. Use {slug} as a placeholder for the per-address slug.
  # For healthchecks.io use: https://hc-ping.com/{slug}
  # For a self-hosted instance use e.g.: https://hc.example.com/ping/<project-token>/{slug}
  url_template: https://hc-ping.com/{slug}
  # Optional prefix prepended to the generated slug for each address.
  # The slug is: slug_prefix + email address with @ and . stripped.
  # Example: prefix "email-fwd-" + "user@example.com" -> "email-fwduserexamplecom"
  slug_prefix: "email-fwd-"

Create one check per monitored address in healthchecks.io, naming the slug to match the pattern above (slug_prefix + address with @ and . removed). Set the check period to slightly above daemon.check_interval_minutes so you get alerted when a run is missed entirely.

Metadata

Release files for email-forwarding-checker 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for email-forwarding-checker 0.6.1
File Size Uploaded
email_forwarding_checker-0.6.1.tar.gz 38.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for email-forwarding-checker 0.6.1
File Interpreter ABI Platform
email_forwarding_checker-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 60.7 kB

Release files / email_forwarding_checker-0.6.1.tar.gz

Download URL email_forwarding_checker-0.6.1.tar.gz
Size 38.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3ac2bc2740028a1ac1167fef1e5bf2730b2a4646b2142df88be3f72053686c1f
BLAKE2b-256 checksum
How to use checksums
239c37f41f3b9943be638494eda42df83d6ce5aedcf11cc055cf0936e1cbc44e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / email_forwarding_checker-0.6.1-py3-none-any.whl

Download URL email_forwarding_checker-0.6.1-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fbe51af4f84d0d816a9c15ff077a03a0073ef51f8545495cdbcb2c0a1073be4
BLAKE2b-256 checksum
How to use checksums
e740486344d4f3cdcd5c9a81f16c06019603c8ef9579e38757c4f45bbf8739e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page