{ "info": { "author": "Jeff Vandrew Jr", "author_email": "jeffvandrew@protonmail.ch", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Flask-EZMail\n\nFlask-EZMail is easier email for Flask. \n\nFlask-EZMail is a fork of Flask-Mail. it maintains high compatibility with Flask-Mail, such that very little code refactoring is needed to switch from one to the other.\n\nFlask-Mail is a convenient wrapper for smtlib, but it requrires that SMTP settings be loaded on app creation. If your user is entering SMTP settings via a web interface, it's not optimal and requires workarounds.\n\nFlask-EZMail is designed to be flexible. You can load SMTP settings at app creation like you would with Flask-Mail, or you can load them at any later time if your user is setting them through an web admin panel. Check out the examples below!\n\n## Installation\n```bash\npip install flask-ezmail\n```\n\n## Creating an Email Object\n\nLet's say you want to load SMTP settings at app creation and never change them, just like Flask-Mail would expect:\n```python3\n# app/__init__.py\n...\nfrom flask_ezmail import Mail\n...\n\n\n\nmail = Mail(\n server=app.config['MAIL_SERVER'],\n username=app.config['MAIL_USERNAME'],\n password=app.config['MAIL_PASSWORD'],\n port=app.config['MAIL_PORT'],\n use_tls=True,\n default_sender=app.config['DEFAULT_SENDER'],\n debug=app.debug\n)\n```\n\nIn that example, you'd have a global variable called `mail` that you'd be able to import in your other modules using `from app import mail`. There's nothing special there, as that's similar to Flask-Mail. \n\nBut here is where the flexibility comes in! Let's instead say your user fills out a form in the admin panel that sets SMTP settings later, after app creation. We'll assume you've defined that as `EmailSetupForm` in your `app.models`. You could then set up mail this way instead:\n\n```python3\nfrom app.models import EmailSetupForm\nfrom flask_ezmail import Mail\n\nform = EmailSetupForm()\n\nmail = Mail(\n server=form.server.data,\n username=form.username.data,\n password=form.password.data,\n port=form.port.data,\n use_tls=True,\n default_sender=form.default_sender.data,\n debug=False\n)\n```\nYou now have a mail object created on the fly! You'll probably want to stash it for later use elsewhere in your app. You have lots of options regarding how to do that:\n\n1. You could pickle it and save it to redis:\n```python3\nimport pickle\n\n# this assumes you've set up redis in app/__init__.py\ncurrent_app.redis.set('mail', pickle.dumps(mail))\n```\nAlternatively if you're using Flask-SQLAlchemy, you could create an email model that inherits from `Mail`, and save it that way instead:\n```python3\n# app/models.py\n\nfrom flask_ezmail import Mail\n\nclass Email(Mail, db.Model):\n __table_args__ = {'extend_existing': True}\n id = db.Column(db.Integer, primary_key=True)\n server = db.Column(db.String(128))\n port = db.Column(db.Integer)\n username = db.Column(db.String(128))\n password = db.Column(db.String(128))\n default_sender = db.Column(db.String(128))\n outgoing_email = db.Column(db.String(128))\n use_tls = db.Column(db.Boolean)\n use_ssl = db.Column(db.Boolean)\n debug = db.Column(db.Boolean, default=False)\n max_emails = db.Column(db.Integer)\n suppress = db.Column(db.Boolean)\n```\nIf you went the SQLAlchemy route, any time you need to grab your email client you'd just:\n```python3\nmail = Email.query.first()\n```\nAnd if you needed to change an SMTP setting on the fly:\n```python3\nfrom app import db\nfrom app.models import Email\n\nmail = Email.query.first()\nif mail is not None:\n mail.server = 'example.net'\n db.session.commit()\n```\nSending a message uses the same Message object as Flask-Mail (cloned in Flask-EZMail).\n```python3\nfrom flask_ezmail import Message\n\nmsg = Message(\n 'Test Message',\n sender='sender@sender.com',\n recipients=['recipient@recipient.com'],\n)\nmail.send(msg)\n```\nFlask-EZmail likewise uses the same `connect()` method as Flask-Mail.\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/JeffVandrewJr/flask-ezmail", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "flask-ezmail", "package_url": "https://pypi.org/project/flask-ezmail/", "platform": "", "project_url": "https://pypi.org/project/flask-ezmail/", "project_urls": { "Homepage": "https://github.com/JeffVandrewJr/flask-ezmail" }, "release_url": "https://pypi.org/project/flask-ezmail/0.6.3/", "requires_dist": [ "blinker" ], "requires_python": "", "summary": "Flask extension for sending email", "version": "0.6.3" }, "last_serial": 4712704, "releases": { "0.6.2": [ { "comment_text": "", "digests": { "md5": "a7d7ffb68b7073a9f775bf210deccbee", "sha256": "3a7fd2d3578bb87837e794afba0b0fe9a21d65760348e361a80e8e6a7a7ea969" }, "downloads": -1, "filename": "flask_ezmail-0.6.2-py3-none-any.whl", "has_sig": false, "md5_digest": "a7d7ffb68b7073a9f775bf210deccbee", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13669, "upload_time": "2019-01-18T02:26:46", "url": "https://files.pythonhosted.org/packages/b7/a0/eea779bf6bac74d3ee12fd99aa6febe23914432643b7920e8db63d971c0e/flask_ezmail-0.6.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d641d7ff3992c9fb14a81a25b991201f", "sha256": "779fe42fddf8f7cccc24f75e3f97b2caaf98bc1378dae5916b9621716d292751" }, "downloads": -1, "filename": "flask-ezmail-0.6.2.tar.gz", "has_sig": false, "md5_digest": "d641d7ff3992c9fb14a81a25b991201f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7347, "upload_time": "2019-01-18T02:26:47", "url": "https://files.pythonhosted.org/packages/7b/c3/ff413dbbb0f3a28c249105d1ffbc81dd50181089f03020b4021dd027a1bc/flask-ezmail-0.6.2.tar.gz" } ], "0.6.3": [ { "comment_text": "", "digests": { "md5": "f302edaa5e6fdc2907772869b3e79e88", "sha256": "c8337a199c5bc7f6fa55eac291c087089ae4f71170d218a8295b5fec686566b5" }, "downloads": -1, "filename": "flask_ezmail-0.6.3-py3-none-any.whl", "has_sig": false, "md5_digest": "f302edaa5e6fdc2907772869b3e79e88", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15301, "upload_time": "2019-01-18T15:30:01", "url": "https://files.pythonhosted.org/packages/1f/ce/4c8fa084fc51f0fddbfd2686fd9c83a2a9312b4bc451cca67cbc5121a9b4/flask_ezmail-0.6.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4627d427bd518df7a8ac05b0e55741e7", "sha256": "ef416a048672b29c20a40a926b50b5ad9b4097744078da626607c5a0e2066caa" }, "downloads": -1, "filename": "flask-ezmail-0.6.3.tar.gz", "has_sig": false, "md5_digest": "4627d427bd518df7a8ac05b0e55741e7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8575, "upload_time": "2019-01-18T15:30:02", "url": "https://files.pythonhosted.org/packages/a5/95/ab12d43632299c287a75c0693666e40487c417c7412455ac4d3449806e18/flask-ezmail-0.6.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f302edaa5e6fdc2907772869b3e79e88", "sha256": "c8337a199c5bc7f6fa55eac291c087089ae4f71170d218a8295b5fec686566b5" }, "downloads": -1, "filename": "flask_ezmail-0.6.3-py3-none-any.whl", "has_sig": false, "md5_digest": "f302edaa5e6fdc2907772869b3e79e88", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15301, "upload_time": "2019-01-18T15:30:01", "url": "https://files.pythonhosted.org/packages/1f/ce/4c8fa084fc51f0fddbfd2686fd9c83a2a9312b4bc451cca67cbc5121a9b4/flask_ezmail-0.6.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4627d427bd518df7a8ac05b0e55741e7", "sha256": "ef416a048672b29c20a40a926b50b5ad9b4097744078da626607c5a0e2066caa" }, "downloads": -1, "filename": "flask-ezmail-0.6.3.tar.gz", "has_sig": false, "md5_digest": "4627d427bd518df7a8ac05b0e55741e7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8575, "upload_time": "2019-01-18T15:30:02", "url": "https://files.pythonhosted.org/packages/a5/95/ab12d43632299c287a75c0693666e40487c417c7412455ac4d3449806e18/flask-ezmail-0.6.3.tar.gz" } ] }