Skip to main content

asyncio version of smtplib

Project description

Introduction

Aiosmtplib is an implementation of the python stdlib smtplib using asyncio, for use in asynchronous applications.

Basic usage:

import asyncio
import aiosmtplib

loop = asyncio.get_event_loop()
smtp = aiosmtplib.SMTP(hostname='localhost', port=1025, loop=loop)
loop.run_until_complete(smtp.connect())

async def send_a_message():
    sender = 'root@localhost'
    recipient = 'somebody@localhost'
    message = "Hello World"
    await smtp.sendmail(sender, [recipient], message)


loop.run_until_complete(send_a_message())

Connecting to an SMTP server

Initialize a new aiosmtplib.SMTP instance, then run it’s connect coroutine. Unlike the standard smtplib, initializing an instance does not automatically connect to the server.

Sending messages

Use SMTP.sendmail to send raw messages. Allowed arguments are:
  • sender : The address sending this mail.

  • recipientsA list of addresses to send this mail to. A bare

    string will be treated as a list with 1 address.

  • message : The message string to send.

  • mail_optionsList of options (such as ESMTP 8bitmime) for the

    mail command.

  • rcpt_optionsList of options (such as DSN commands) for

    all the rcpt commands.

Use SMTP.send_message to send email.message.Message objects.

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

aiosmtplib-0.1.4.tar.gz (10.8 kB view details)

Uploaded Source

File details

Details for the file aiosmtplib-0.1.4.tar.gz.

File metadata

  • Download URL: aiosmtplib-0.1.4.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiosmtplib-0.1.4.tar.gz
Algorithm Hash digest
SHA256 f56a53124cc343f036120dbd0b4729d14aaa5725a32de49881713edc2e561402
MD5 d9c7a21d17e88caef9a261ed61e981dd
BLAKE2b-256 050179536a2f9d72dbc81b9c1cd003b4c28de02a10b0e272a3be0cfd0f78d229

See more details on using hashes here.

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