mentortools/libs/: email-tools-abm-0.1.66881 metadata and description

Simple index

Sending emails via email services

author Vasya Svintsov
author_email v.svintsov@technokert.ru
classifiers
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3.11
description_content_type text/markdown
requires_dist
  • aioboto3 (==8.2.0)
  • aiohttp (>=3.11.7,<4.0.0)
  • aiosmtplib (>=3.0.2,<4.0.0)
  • beautifulsoup4 (>=4.12.3,<5.0.0)
  • dict-caster-abm (>=1.1.52868,<2.0.0)
  • furl (>=2.1.3,<3.0.0)
  • http-tools-abm (==5.4.62496)
requires_python >=3.11,<4.0
File Tox results History
email_tools_abm-0.1.66881-py3-none-any.whl
Size
13 KB
Type
Python Wheel
Python
3
email_tools_abm-0.1.66881.tar.gz
Size
6 KB
Type
Source

Welcome to EmailSender

Asynchronous SMTP/AmazonSES/HTTP(SelfEmailSender) client for asyncio and Python.

Library Installation

pip install --extra-index-url https://pypi2.abm-jsc.ru email-tools-abm

Quick Start

Send email using SMTP client

import asyncio
from email_tools.email_sender import EmailSender
from http_tools.attached_file import AttachedFile

async def send_email_using_smtp_client():
    email_sender = EmailSender(
        config=EmailSender.SMTPConfig(
            server_hostname="smtp.gmail.com",
            server_ssl_port=465,
            username="example@gmail.com",
            password="password",
            default_from_email="example@gmail.com",
        ), 
        context=EmailSender.Context()
    )
    await email_sender.send(
        to_recipients=["v.svintsov@technokert.ru", "v.svintsov.2@technokert.ru"], 
        subject="ExampleSubject", 
        body="ExampleBody",
        attachments=[AttachedFile(b"1", "file1", "application"), AttachedFile(b"", "file2", "application")]
    )


asyncio.run(send_email_using_smtp_client())

Send email using AmazonSES client

import asyncio
from email_tools.email_sender import EmailSender


async def send_email_using_amazon_ses_client():
    email_sender = EmailSender(
        config=EmailSender.AmazonSESConfig(
            access_key="access_key",
            secret_key="secret_key",
            region_name="eu-central-1",
            default_from_email="example@verifiedcompany.com",
        ),
        context=EmailSender.Context()
    )
    await email_sender.send(
        to_recipients="v.svintsov@technokert.ru", 
        subject="ExampleSubject", 
        body="ExampleBody",
        cc_recipients="CC.v.svintsov@technokert.ru"
    )


asyncio.run(send_email_using_amazon_ses_client())

Send email using OuterHttpServer with EmailSender client

import asyncio
from email_tools.email_sender import EmailSender
from aiohttp import ClientSession


async def send_email_using_outer_email_sender():
    email_sender = EmailSender(
        config=EmailSender.HTTPConfig(
            location="http://outer_email_sender",
        ),
        context=EmailSender.Context(
            session=ClientSession()
        )
    )
    await email_sender.send(
        to_recipients="v.svintsov@technokert.ru", 
        subject="ExampleSubject", 
        body="ExampleBody",
        cc_recipients=["CC.v.svintsov@technokert.ru"],
        bcc_recipients="BCC.v.svintsov@technokert.ru",
    )


asyncio.run(send_email_using_outer_email_sender())