# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['mailers']

package_data = \
{'': ['*']}

install_requires = \
['aiosmtplib>=1.1.6,<2.0.0']

setup_kwargs = {
    'name': 'mailers',
    'version': '1.0.0',
    'description': 'Email delivery for asyncio.',
    'long_description': '# Mailers for asyncio\n\n![PyPI](https://img.shields.io/pypi/v/mailers)\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/alex-oleshkevich/mailers/Lint)\n![GitHub](https://img.shields.io/github/license/alex-oleshkevich/mailers)\n![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/pypi/mailers)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/mailers)\n![GitHub Release Date](https://img.shields.io/github/release-date/alex-oleshkevich/mailers)\n![Lines of code](https://img.shields.io/tokei/lines/github/alex-oleshkevich/mailers)\n\n\n## Installation\n\n```bash\npip install mailers\n```\n\n## Usage\n\nThe package uses two main concepts: mailers and transports. The mailer is a class which abstracts you from the\nunderlying transport and the transport does the actual message delivery.\n\n```python\nfrom mailers import add_mailer, EmailMessage, send\n\nadd_mailer(\'smtp://user:password@localhost:25?timeout=2\', name=\'default\')\n\nmessage = EmailMessage(\n    to=\'user@localhost\', from_address=\'from@localhost\',\n    subject=\'Hello\', text_body=\'World!\'\n)\nawait send(\'user@localhost\', message)\n```\n\nOr if you prefer more control on what is going one, take this more verbose path:\n\n```python\nfrom mailers import Mailer, SMTPTransport, EmailMessage\n\nmailer = Mailer(SMTPTransport(\'localhost\', 25))\n\nmessage = EmailMessage(\n    to=\'user@localhost\', from_address=\'from@localhost\',\n    subject=\'Hello\', text_body=\'World!\'\n)\nawait mailer.send(message)\n```\n\n## Compose messages\n\nThe arguments and methods of `EmailMessage ` class are self-explanatory so here is some basic example:\n\n```python\nfrom mailers import EmailMessage, Attachment\n\nmessage = EmailMessage(\n    to=\'user@localhost\',\n    from_address=\'from@example.tld\',\n    cc=\'cc@example.com\',\n    bcc=[\'bcc@example.com\'],\n    text_body=\'Hello world!\',\n    html_body=\'<b>Hello world!</b>\',\n    attachments=[\n        Attachment(\'CONTENTS\', \'file.txt\', \'text/plain\'),\n    ]\n)\n\n# attachments can be added on demand:\n\nwith open(\'file.txt\', \'r\') as f:\n    message.attach(f.read(), f.name, \'text/plain\')\n\n    # alternatively\n    message.add_attachment(\n        Attachment(f.read(), f.name, \'text/plain\')\n    )\n```\n\n`cc`, `bcc`, `to`, `reply_to` can be either strings or lists of strings.\n\n### A note about attachments\n\nAccessing files is a blocking operation. You may want to use `aiofiles` or alternate library which reads files in\nnon-blocking mode.\n\nThis package does not implement direct access to files at moment. This is something to do at later stage.\n\n## Transports\n\n### Preinstalled transports\n\nAll transport classes can be found in `mailers.transports` module.\n\n| Class             | Example URL                                       | Description                                                       |\n|-------------------|---------------------------------------------------|-------------------------------------------------------------------|\n| SMTPTransport     | smtp://user:pass@hostname:port?timeout=&use_tls=1 | Sends mails using SMTP protocol.                                  |\n| InMemoryTransport | not available                                     | Stores sent messages in the local variable. See an example below. |\n| FileTransport     | file:///path/to/directory                         | Writes sent messages into directory.                              |\n| NullTransport     | null://                                           | Does not perform any sending.                                     |\n| StreamTransport   | not available                                     | Writes message to an open stream. See an example below.           |\n| ConsoleTransport  | console://                                        | Prints messages into stdout.                                      |\n| GMailTransport    | gmail://username:password                         | Sends via GMail.                                                  |\n| MailgunTransport  | mailgun://username:password                       | Sends via Mailgun.                                                |\n\n### Special notes\n\n#### InMemoryTransport\n\n`InMemoryTransport` takes a list and writes outgoing mail into it. Read this list to inspect the outbox.\n\n```python\nfrom mailers import InMemoryTransport, EmailMessage\n\nmessage = EmailMessage(from_address=\'noreply@localhost\')\nmailbox = []\ntransport = InMemoryTransport(mailbox)\nawait transport.send(message)\n\nassert message in mailbox\n```\n\n#### StreamTransport\n\nWrites messages into the open stream.\n\n```python\nfrom mailers import StreamTransport, EmailMessage\nfrom io import StringIO\n\nmessage = EmailMessage(from_address=\'noreply@localhost\')\n\ntransport = StreamTransport(output=StringIO())\nawait transport.send(message)\n```\n\n`output` is any IO compatible object.\n\n### Custom transports.\n\nEach transport must implement `async def send(self, message: EmailMessage) -> None` method. Preferably, inherit\nfrom `BaseTransport` class:\n\n```python\nfrom mailers import BaseTransport, Mailer, EmailMessage\n\n\nclass PrintTransport(BaseTransport):\n    async def send(self, message: EmailMessage) -> None\n        print(str(message))\n\n\nmailer = Mailer(transport=PrintTransport())\n```\n\nIn order to make your transport to accept `EmailURL` instances, your transport class has to implement `from_url`\nclass method:\n\n```python\nfrom mailers import BaseTransport, EmailURL\n\n\nclass PrintTransport(BaseTransport):\n    @classmethod\n    def from_url(cls, url: EmailURL) -> "PrintTransport":\n        return cls()\n```\n\n### Add custom transport protocols.\n\nOnce you build a custom transport you can add it\'s URL to enable URL-based configurations.\n\n```python\nfrom mailers import add_protocol_handler, Mailer, BaseTransport, EmailURL, create_from_url\n\nclass PrintTransport(BaseTransport):\n    @classmethod\n    def from_url(cls, url: EmailURL) -> "PrintTransport":\n        return cls()\n\nadd_protocol_handler(\'myprotocol\', PrintTransport)\n\nmailer = Mailer(transport=create_from_url(\'myprotocol://\'))\n```\n\nNote that the transport must to implement `from_url` method to accept URL parameters. Otherwise it will be constructed\nwithout any arguments passed to the `__init__` method.\n',
    'author': 'alex.oleshkevich',
    'author_email': 'alex.oleshkevich@gmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/alex-oleshkevich/mailers',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
