{ "info": { "author": "Drew Bednar", "author_email": "drew@androiddrew.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "# apistar-mail\n\n[![PyPI](https://img.shields.io/pypi/v/apistar-mail.svg)](https://pypi.org/project/apistar-mail/)\n[![PyPI](https://img.shields.io/pypi/pyversions/apistar-mail.svg)](https://pypi.org/project/apistar-mail/)\n[![Build Status](https://travis-ci.org/androiddrew/apistar-mail.svg?branch=master)](https://travis-ci.org/androiddrew/apistar-mail)\n[![codecov](https://codecov.io/gh/androiddrew/apistar-mail/branch/master/graph/badge.svg)](https://codecov.io/gh/androiddrew/apistar-mail)\n\n\nProvides a simple interface to set up SMTP with your [APIStar](https://github.com/encode/apistar) application and send messages from your view functions. Please note this work derives largely from the [Flask-Mail](https://github.com/mattupstate/flask-mail) extension by 'Dan Jacob' and contributors, but has been modified extensively to remove Python 2 support and be used as an APIStar component.\n\n\n## Installation\n\n`$ pip install apistar-mail`\n\n## Usage\n\n### Example Setup\n\nTo send mail messages from your view functions you must include a dictionary of mail options to the `MailComponent`. Here we have a minimally viable app capable of sending an email message and returning a 204 response code:\n\n```python\nfrom apistar import App, Route\nfrom apistar.http import Response\nfrom apistar_mail import MailComponent, Mail, Message\n\nmail_options = {\n 'MAIL_SERVER': 'smtp.example.com',\n 'MAIL_USERNAME': 'me@example.com',\n 'MAIL_PASSWORD': 'dontcommitthistoversioncontrol',\n 'MAIL_PORT': 587,\n 'MAIL_USE_TLS': True,\n 'MAIL_DEFAULT_SENDER': 'me@example.com'\n}\n\n\ndef send_a_message(mail: Mail):\n msg = Message(subject='Hello',\n body='Welcome to APIStar!',\n recipients=['you@example.com'])\n mail.send(msg)\n return Response('', 204)\n\n\nroutes = [\n Route('/', 'POST', send_a_message)\n]\n\ncomponents = [\n MailComponent(**mail_options)\n]\n\napp = App(\n routes=routes,\n components=components\n)\n\nif __name__ == '__main__':\n app.serve('127.0.0.1', 5000, debug=True)\n\n```\n\n### Sending Messages\n\nTo send a message ,first include the Mail component for injection into your view. Then create an instance of Message, and pass it to your Mail component using `mail.send(msg)`\n\n```python\nfrom apistar_mail import Mail, Message\n\ndef send_a_message(mail:Mail):\n msg = Message('Hello',\n sender='drew@example.com',\n recipients=['you@example.com'])\n mail.send(msg)\n return\n```\n\nYour message recipients can be set in bulk or individually:\n\n```python\nmsg.recipients = ['you@example.com', 'me@example.com']\nmsg.add_recipient('otherperson@example.com')\n```\n\nIf you have set `MAIL_DEFAULT_SENDER` you don\u2019t need to set the message sender explicitly, as it will use this configuration value by default:\n\n```python\nmsg = Message('Hello',\n recipients=['you@example.com'])\n```\n\nThe sender can also be passed as a two element tuple containing a name and email address which will be split like so:\n\n```python\nmsg = Message('Hello',\n sender=('Me', 'me@example.com'))\n\nassert msg.sender == 'Me '\n```\n\nA Message can contain a body and/or HTML:\n\n```python\nmsg.body = 'message body'\nmsg.html = 'Hello apistar_mail!'\n```\n\n### Configuration Options\n\napistar-mail is configured through the inclusion of the `MAIL` dictionary in your apistar settings. These are the available options:\n\n* 'MAIL_SERVER': default 'localhost'\n* 'MAIL_USERNAME': default None\n* 'MAIL_PASSWORD': default None\n* 'MAIL_PORT': default 25\n* 'MAIL_USE_TLS': default False\n* 'MAIL_USE_SSL': default False\n* 'MAIL_DEFAULT_SENDER': default None\n* 'MAIL_DEBUG': default False\n* 'MAIL_MAX_EMAILS': default None\n* 'MAIL_SUPPRESS_SEND': default False\n* 'MAIL_ASCII_ATTACHMENTS': False\n\n\n## Testing\n\nTo run the test suite with coverage first install the package in editable mode with it's testing requirements:\n\n`$ pip install -e \".[testing]\"`\n\nTo run the project's tests\n\n`$ pytest --cov`\n\nTo run tests against multiple python interpreters use:\n\n`$ tox`\n\n# HISTORY\n\n0.3.0 Added support for APIStar version >= 0.4.0\n\n0.2.1 Pinned APIStar requirement to 0.3.9\n\nAPIStar 0.4.0 introduced breaking changes to the framework. Since Components have completely changed we are pinning the requirement for this release.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/androiddrew/apistar-mail", "keywords": "apistar-mail apistar_mail mail SMTP", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "apistar-mail", "package_url": "https://pypi.org/project/apistar-mail/", "platform": "", "project_url": "https://pypi.org/project/apistar-mail/", "project_urls": { "Homepage": "https://github.com/androiddrew/apistar-mail" }, "release_url": "https://pypi.org/project/apistar-mail/0.3.0/", "requires_dist": [ "apistar (>=0.4)", "pytest; extra == 'testing'", "pytest-cov; extra == 'testing'", "tox; extra == 'testing'" ], "requires_python": "", "summary": "A simple email Component for APIStar", "version": "0.3.0" }, "last_serial": 3862972, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "c7579e60e8cabd92fb1c48dc05384e37", "sha256": "cf96d85eb9b909294a56bbccb6f7a29cdbf8c4c1509fec38a259257f36470e7b" }, "downloads": -1, "filename": "apistar_mail-0.2.0-py35-none-any.whl", "has_sig": false, "md5_digest": "c7579e60e8cabd92fb1c48dc05384e37", "packagetype": "bdist_wheel", "python_version": "py35", "requires_python": null, "size": 11031, "upload_time": "2018-01-30T17:40:01", "url": "https://files.pythonhosted.org/packages/aa/98/6e1d28bc7ae843309583d95b776783f11840c844881e4144f3fa19749323/apistar_mail-0.2.0-py35-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8150e413dfeaed359565a84be081c806", "sha256": "b080e2ca37d0e98b5f2cc52379037dba1b843e893dd2834827dbe96e9e9bbd18" }, "downloads": -1, "filename": "apistar-mail-0.2.0.tar.gz", "has_sig": false, "md5_digest": "8150e413dfeaed359565a84be081c806", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12651, "upload_time": "2018-01-30T17:40:02", "url": "https://files.pythonhosted.org/packages/46/38/3a49432387aad8f4515cd350e7c645bb00babc6f0f145490d8291bdcc962/apistar-mail-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "1fcfb46a4ccafb177cbb273d7a210e45", "sha256": "3ce3a91c9c5f41547a5565c3c903d1ef19a8c9fc2c57080a8447834d9e2bb5ae" }, "downloads": -1, "filename": "apistar_mail-0.2.1-py35-none-any.whl", "has_sig": false, "md5_digest": "1fcfb46a4ccafb177cbb273d7a210e45", "packagetype": "bdist_wheel", "python_version": "py35", "requires_python": null, "size": 11149, "upload_time": "2018-05-14T17:04:16", "url": "https://files.pythonhosted.org/packages/1a/db/eb4dca1d038f2079cce7aa35e454e77def15d36dfc41bcdc38fdf6dc58c8/apistar_mail-0.2.1-py35-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f4d3863a5b6f74e1a51e35411e611b68", "sha256": "225272dd8016c5af997fa32295e616638dabe0ab9c50a8c650e85130ff6677b6" }, "downloads": -1, "filename": "apistar-mail-0.2.1.tar.gz", "has_sig": false, "md5_digest": "f4d3863a5b6f74e1a51e35411e611b68", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12831, "upload_time": "2018-05-14T17:04:17", "url": "https://files.pythonhosted.org/packages/47/cb/d4994e2bb62e298bd18fe40c905ee544c7c9dc0e4cefc5bd9634b2b280b9/apistar-mail-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "c6ed214cfa3c3779ff0187264fa79f44", "sha256": "147797587f2421ca7e5e9c4467915a59ee74ca948c5603fd241698e42640e538" }, "downloads": -1, "filename": "apistar_mail-0.3.0-py35-none-any.whl", "has_sig": false, "md5_digest": "c6ed214cfa3c3779ff0187264fa79f44", "packagetype": "bdist_wheel", "python_version": "py35", "requires_python": null, "size": 8754, "upload_time": "2018-05-15T01:52:34", "url": "https://files.pythonhosted.org/packages/74/22/6400782e2a5ee650db6d1abd7c40aa8a06cff0c8adf1d97902e765378752/apistar_mail-0.3.0-py35-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1e683682c14f88218793d2af16566946", "sha256": "9c5615760401368fad9d705bcda5353b049f2c7a133ab36fd274bb746afe95c7" }, "downloads": -1, "filename": "apistar-mail-0.3.0.tar.gz", "has_sig": false, "md5_digest": "1e683682c14f88218793d2af16566946", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12992, "upload_time": "2018-05-15T01:52:36", "url": "https://files.pythonhosted.org/packages/c4/52/00f2c20bffcbb25d89a9e0fed606a373a03a9ed06cb5f70204895f43960f/apistar-mail-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c6ed214cfa3c3779ff0187264fa79f44", "sha256": "147797587f2421ca7e5e9c4467915a59ee74ca948c5603fd241698e42640e538" }, "downloads": -1, "filename": "apistar_mail-0.3.0-py35-none-any.whl", "has_sig": false, "md5_digest": "c6ed214cfa3c3779ff0187264fa79f44", "packagetype": "bdist_wheel", "python_version": "py35", "requires_python": null, "size": 8754, "upload_time": "2018-05-15T01:52:34", "url": "https://files.pythonhosted.org/packages/74/22/6400782e2a5ee650db6d1abd7c40aa8a06cff0c8adf1d97902e765378752/apistar_mail-0.3.0-py35-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1e683682c14f88218793d2af16566946", "sha256": "9c5615760401368fad9d705bcda5353b049f2c7a133ab36fd274bb746afe95c7" }, "downloads": -1, "filename": "apistar-mail-0.3.0.tar.gz", "has_sig": false, "md5_digest": "1e683682c14f88218793d2af16566946", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12992, "upload_time": "2018-05-15T01:52:36", "url": "https://files.pythonhosted.org/packages/c4/52/00f2c20bffcbb25d89a9e0fed606a373a03a9ed06cb5f70204895f43960f/apistar-mail-0.3.0.tar.gz" } ] }