Skip to main content

Asynchronous Gmail Client

Project description

This is an asynchronous Gmail client that can send emails currently.

Quickstart

import asyncio
import logging
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

import aiogmailsender

async def arun():
    sender = await aiogmailsender.create('<gmailusername>',
                                         '<gamilpassword>',
                                         rate_limit=60, # How many emails sender sends within a minute
                                         pool_size=2, # How many clients are kept in pool
                                         retry=5, # How many times sender retries to send a message, when sending fails
                                         backoff=30, # How long sender sleep before retry (unit. seconds)
                                         backoff_limit=300 # Max backoff (everytime sender retries, the backoff time increases exponentially and the time can't be over this limit.)
                                         )

    tasks = []
    for i in range(10):
        message = MIMEMultipart('alternative')
        message["From"] = 'test'
        message["To"] = '<targetemail>'
        message["Subject"] = f'test {i}'

        part = MIMEText('test', 'html')
        message.attach(part)
        tasks.append(sender.send(message))

    await asyncio.gather(*tasks)


if __name__ == '__main__':
    logging.basicConfig(format="%(asctime)s %(levelname)s:%(name)s:%(message)s", level=logging.DEBUG)
    asyncio.run(arun())

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

aiogmailsender-0.0.3.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file aiogmailsender-0.0.3.tar.gz.

File metadata

  • Download URL: aiogmailsender-0.0.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for aiogmailsender-0.0.3.tar.gz
Algorithm Hash digest
SHA256 634a575fe34af498c1303e843a6158aab42de78ac293dffa52a09b99085b3119
MD5 ed41b3f73c44bf08e9968c5c1632a84d
BLAKE2b-256 42259fb66f95efbd474f8dde269284068decb0e437d9d379858dac583212c22e

See more details on using hashes here.

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