Skip to main content

Simple sending of smtp emails using env variables

Project description

envsmtp

Latest Release envsmtp on pypi MIT License unittests Status

Simple sending of smtp emails using environment variables

Install

envsmtp on pypi

pip install --upgrade envsmtp

Environment Variables

You must set SMTP_USER and SMTP_PASS in your environment with your user and password!

See additional optional settings in example.env

Usage

This package will by default use STARTTLS settings for smtp.gmail.com on port 587. If you wish to change these settings, you can set your own environment variables for SMTP_HOST and SMTP_PORT

Once installed, here's a simple example of how to use this package:

from envsmtp import EmailMessage

msg = EmailMessage(
    sender="sender@example.com",
    receipients="receipient@example.com",
    subject="envsmtp test",
    body="This is just a test message",
)
msg.smtp_send()

To send with attachments:

from envsmtp import EmailMessage, EmailAttachment

attachments = [
    EmailAttachment(content='/path/to/file.txt'),
    EmailAttachment(content=b'randombytes', filename='bytes_test.txt'),
    EmailAttachment(content='/path/to/another.txt', filename='this_name_is_different_.txt')
]
msg = EmailMessage(
    sender="sender@example.com",
    receipients="receipient@example.com",
    subject="envsmtp test",
    body="This is just a test message",
    attachments=attachments,
)
msg.smtp_send()

Requirements

Tested with & designed for python 3.10, see requirements.txt for additional dependencies

Contributing

For bugs / feature requests please submit issues

Open Issues Closed Issues

If you would like to contribute to this project, you are welcome to submit a pull request

Open Pull Requests Closed Pull Requests

Warranty / Liability / Official support

This project is being developed independently, we provide the package "as-is" without any implied warranty or liability, usage is your own responsibility

Additional info

Just because I like badges

Pypi downloads per month Pypi downloads per week Pypi downloads per day

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

envsmtp-0.0.2.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

envsmtp-0.0.2-py3-none-any.whl (4.3 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