Skip to main content

Email notifications when a code block or function finishes or ends unexpectedly.

Project description

Email Notify

Email notifications when a code block or function finishes or ends unexpectedly.

Use SMTP service.

Configuration

Before using, you need to configure your email account and SMTP server.

import email_notify

# Set email address and application password (will be encrypted and saved if save=True)
email_notify.auth(save=True)

# Set SMTP server host and port (will be saved if save=True)
email_notify.smtp(save=True)

Configuration is saved in $HOME/.email_notify.config. Call forget() to remove the saved configuration.

Usage

You can use email_notify in three ways:

  • As a context manager (recommended)
  • As a decorator
  • Calling email_notify.send(subject, message, recipient) directly

Context Manager (recommended)

import email_notify

recipient = 'user@example.com'

with email_notify.context(recipient, task_name='Task'):
    print('Running some tasks...')
    # some tasks

Decorator

import email_notify

recipient = 'user@example.com'

@email_notify.decorator(recipient)
def my_task():
    print('Running some tasks...')
    # some tasks

my_task()

Direct Send

import email_notify

recipient = 'user@example.com'

try:
    print('Running some tasks...')
    # some tasks
except Exception as e:
    subject = 'Task Failed'
    message = f'The task failed with error:\n{e}'
    email_notify.send(subject, message, recipient)
else:
    subject = 'Task Completed'
    message = f'The task finished successfully.\nResult: {result}'
    email_notify.send(subject, message, recipient)

Installation

pip install email_notify

Requirements

  • cryptography

Note

Make sure you know your SMTP service host and port before configuring.

Known SMTP service hosts and ports (updated 2025-6-8):

Provider SMTP Host SMTP Port
QQ Mail smtp.qq.com 465 or 587

For other providers, please refer to your email service documentation or contact your administrator.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

email_notify-1.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

email_notify-1.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file email_notify-1.1.0.tar.gz.

File metadata

  • Download URL: email_notify-1.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for email_notify-1.1.0.tar.gz
Algorithm Hash digest
SHA256 77af0055a9ddc3dbbd91243eb15e29457a7ddfc4003436ed1c2a35d9920909b3
MD5 bf7f7fe4b1584f86ae39ba7ff801cd6a
BLAKE2b-256 cba5cfb8e3ec9255954c2446297743b89e4140a4be5574bf69c7408765616923

See more details on using hashes here.

Provenance

The following attestation bundles were made for email_notify-1.1.0.tar.gz:

Publisher: python-publish.yml on huchaoning/email-notify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file email_notify-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: email_notify-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for email_notify-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64fe065073fd43be22b357d374a41ce6cd67ae660385554fef317ef7db92efb8
MD5 22451fe806677d3917597cc081b91bcf
BLAKE2b-256 fb7af262a8528825a23a59f4d45bec6888a8e2a2bdd13e997a50509f7b2e973d

See more details on using hashes here.

Provenance

The following attestation bundles were made for email_notify-1.1.0-py3-none-any.whl:

Publisher: python-publish.yml on huchaoning/email-notify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page