Skip to main content

Send email messages

Project description

Bote

Supported Python Versions Last commit pypi version

"Bote" is German for messenger or courier. The bote library currently just sends plain-text email from localhost or a remote SMTP server.

There are plenty of libraries for this. My reasons to write another one:

  • Modularity: I outsourced this code from my exoskeleton library.
  • Extensive testing
  • Type-Hints in the code (PEP 484)
  • Good error messages
  • Enforce that any connection to a SMTP server - except localhost / 127.0.0.1 - is encrypted.
  • Automatically wrap messages to 80 characters.

How to use it

import os
import bote

mail_settings = {
    'server': 'smtp.example.com',
    'server_port': 587,
    'encryption': 'starttls',  # or 'ssl', or 'off'
    # Best practice: get secrets from environment variables
    # instead of hardcoded strings =>
    'username': os.environ.get('MAIL_USER'),
    'passphrase': os.environ.get('MAIL_PASSPHRASE'),
    'recipient': 'foo@example.com',
    'sender': 'bar@example.com'}

mailer = bote.Mailer(mail_settings)

mailer.send_mail('Test bote',  # subject
                 'It worked!'  # mail body
                 )

You should not store secrets in code that may be shared or saved to source control. To avoid accidental exposure of secrets it is best practice to use environment variables that can be accessed with os.environ.get(). The python-dotenv could be useful for this too, but do not forget to add .env files to .gitignore.

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

bote-0.9.1.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

bote-0.9.1-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

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