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=25, loop=loop)

@asyncio.coroutine
def send_a_message():
    sender = 'root@localhost'
    recipient = 'somebody@localhost'
    message = "Hello World"
    yield from smtp.sendmail(sender, [recipient], message)

asyncio.async(send_a_message())
loop.run_forever()

Connecting to an SMTP server

Use an instance of the SMTP class to connect to a server. Note that if the event loop used to initialize the class is not currently running, it will be started in order to connect.

Sending messages

Use SMTP.sendmail to send raw messages. The method signature is the same as for standard smtplib.

Use SMTP.send_message to send email.message.Message objects. The method signature is the same as for standard smtplib.

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.3.tar.gz (10.2 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for aiosmtplib-0.1.3.tar.gz
Algorithm Hash digest
SHA256 454e4420e05fa523d87ab888c7a2bd6205ab14b21e5a3784d22aeaf47c3c6e9b
MD5 af1e14dfdf71368d3ba1b98f1b5a3b45
BLAKE2b-256 7aacab711370e01c3cbba6e92fd85c6d00f0d0d3c6d78acfb1adf9dd496504bc

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