{ "info": { "author": "Alessandro Molina", "author_email": "amol@turbogears.org", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: TurboGears" ], "description": "About tgext.mailer\n-------------------------\n\n.. image:: https://travis-ci.org/amol-/tgext.mailer.png\n :target: https://travis-ci.org/amol-/tgext.mailer\n\n.. image:: https://coveralls.io/repos/amol-/tgext.mailer/badge.png\n :target: https://coveralls.io/r/amol-/tgext.mailer\n\n.. image:: https://img.shields.io/pypi/v/tgext.mailer.svg\n :target: https://pypi.python.org/pypi/tgext.mailer\n\ntgext.mailer is a TurboGears2 extension for sending emails with transaction\nmanager integration. Whenever the transaction manager provided with TurboGears\ncommits the transaction all the emails are sent, when the transaction is\nabort the mails are discarded.\n\nWhile there are other extensions available for sending emails on TurboGears,\nlike TurboMail. Those are not bound to the transaction manager, have a more\ncomplex structure or are not actively maintained anymore. This lead to the\nbirth of ``tgext.mailer``.\n\ntgext.mailer code is adapted from the *pyramid_mailer* project which uses\n``repoze.sendmail`` to perform actual email delivery.\n\n\nInstalling\n-------------------------------\n\ntgext.mailer can be installed from pypi::\n\n pip install tgext.mailer\n\nshould just work for most of the users.\n\nEnabling\n-------------------------------\n\nTo enable tgext.mailer put inside your application\n``config/app_cfg.py`` the following::\n\n import tgext.mailer\n tgext.mailer.plugme(base_config)\n\nor you can use ``tgext.pluggable`` when available::\n\n from tgext.pluggable import plug\n plug(base_config, 'tgext.mailer')\n\ntgext.mailer will then load the options from your application\nconfiguration file, refer to the **Configuration File Options**\nsection for a complete list of available options.\n\nSending Emails\n--------------------------------\n\nSending emails is performed through the mailer object, each request has its\nown mailer object, which is in charge of sending only the emails of that\nrequest. If you don't pass any request to the ``get_mailer`` call, the\napplication wide mailer is returned (Do not use it inside a request)::\n\n from tgext.mailer import get_mailer\n mailer = get_mailer(request)\n\nTo send a message, you must first create a\n``tgext.mailer.message.Message`` instance::\n\n from tgext.mailer import Message\n\n message = Message(subject=\"hello world\",\n sender=\"admin@mysite.com\",\n recipients=[\"john.doe@gmail.com\"],\n body=\"Hi John!\")\n\nThe ``Message`` is then passed to the ``Mailer`` instance. You can either\nsend the message right away::\n\n mailer.send(message)\n\nor add it to your mail queue (a maildir on disk)::\n\n mailer.send_to_queue(message)\n\nIf you want to send the email without registering it on the transaction manager,\nto make sure it gets sent even in case of transaction failures, use::\n\n mailer.send_immediately(message)\n\n\nConfiguration File Options\n--------------------------------\n\nThe available settings are listed below. Place them under ``[app:main]`` in your configuration ``*.ini`` file.\n\n========================== ==================================== ===============================\nSetting Default Description\n========================== ==================================== ===============================\n**mail.debugmailer** **False** Store emails on disk for debugging\n**mail.host** ``localhost`` SMTP host\n**mail.port** ``25`` SMTP port\n**mail.username** **None** SMTP username\n**mail.password** **None** SMTP password\n**mail.tls** **False** Use TLS\n**mail.ssl** **False** Use SSL\n**mail.keyfile** **None** SSL key file\n**mail.certfile** **None** SSL certificate file\n**mail.queue_path** **None** Location of maildir\n**mail.default_sender** **None** Default from address\n**mail.debug** **0** SMTP debug level\n========================== ==================================== ===============================\n\nIn test units that have to check for sent email, make sure to set **mail.debugmailer** to ``\"dummy\"``\nit will save outgoing emails in ``mailer.output`` instead of actually sending them.\n\nTransactions\n------------\n\nIf you are using transaction management then **tgext.mailer** will only \nsend the emails (or add them to the mail queue)\nwhen the transactions are committed.\n\nFor example::\n\n import transaction\n\n from tgext.mailer.mailer import Mailer\n from tgext.mailer import Message\n\n mailer = Mailer()\n message = Message(subject=\"hello world\",\n sender=\"admin@mysite.com\",\n recipients=[\"john.doe@gmail.com\"],\n body=\"Hi John!\")\n\n mailer.send(message)\n transaction.commit()\n\n\nThe email is not actually sent until the transaction is committed.\n\nUsually TurboGears will automatically commit the transaction for your\nat the end of the request so you don't need to explicitly commit or abort\nwithin code that sends mail. Instead, if an exception is raised, the\ntransaction will implicitly be aborted and mail will not be sent; otherwise\nit will be committed, and mail will be sent.\n\nIf you use the **Application wide email manager** it is usually best practice\nto only use ``send_immediately`` method, to avoid registering the same mail manager\nin multiple transactions.\n\nAttachments\n-----------\n\nAttachments are added using the ``tgext.mailer.message.Attachment``\nclass::\n\n from tgext.mailer import Attachment\n from tgext.mailer import Message\n\n message = Message()\n\n photo_data = open(\"photo.jpg\", \"rb\").read()\n attachment = Attachment(\"photo.jpg\", \"image/jpg\", photo_data)\n\n message.attach(attachment)\n\nYou can pass the data either as a string or file object, so the above code\ncould be rewritten::\n\n\n from tgext.mailer import Attachment\n from tgext.mailer import Message\n\n message = Message()\n\n attachment = Attachment(\"photo.jpg\", \"image/jpg\",\n open(\"photo.jpg\", \"rb\"))\n\n message.attach(attachment)\n\nA transfer encoding can be specified via the ``transfer_encoding`` option.\nSupported options are currently ``base64`` (the default) and\n``quoted-printable``.\n\nYou can also pass an attachment as the ``body`` and/or ``html``\narguments to specify ``Content-Transfer-Encoding`` or other\n``Attachment`` attributes::\n\n from tgext.mailer import Attachment\n from tgext.mailer import Message\n\n body = Attachment(data=\"hello, arthur\",\n transfer_encoding=\"quoted-printable\")\n html = Attachment(data=\"
hello, arthur
\",\n transfer_encoding=\"quoted-printable\")\n message = Message(body=body, html=html)\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/amol-/tgext.mailer", "keywords": "turbogears2.extension", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "tgext.mailer", "package_url": "https://pypi.org/project/tgext.mailer/", "platform": "", "project_url": "https://pypi.org/project/tgext.mailer/", "project_urls": { "Homepage": "https://github.com/amol-/tgext.mailer" }, "release_url": "https://pypi.org/project/tgext.mailer/0.3.0/", "requires_dist": null, "requires_python": "", "summary": "TurboGears extension for sending emails with transaction manager integration", "version": "0.3.0" }, "last_serial": 4634180, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "eafdd44fc145859ca2514ae2600291d7", "sha256": "597ebaf3a09428f07bd5afbd3d2d0e7e00d9c1cdd96b130ed95e03656cf0b515" }, "downloads": -1, "filename": "tgext.mailer-0.0.1.tar.gz", "has_sig": false, "md5_digest": "eafdd44fc145859ca2514ae2600291d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14763, "upload_time": "2015-03-19T14:16:52", "url": "https://files.pythonhosted.org/packages/7b/b9/8fd3efe9970eca1cf92f09d1ce86205719f32cb02eeb448b24ef3b1cae55/tgext.mailer-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "ca9d0eee1c81b92f46b651a31d5a52fd", "sha256": "e584a0720a51ea8e80de199e17e8ac50d0fdce37c25d6a6fe5aa5474371d6440" }, "downloads": -1, "filename": "tgext.mailer-0.0.2.tar.gz", "has_sig": false, "md5_digest": "ca9d0eee1c81b92f46b651a31d5a52fd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14142, "upload_time": "2015-07-30T11:52:56", "url": "https://files.pythonhosted.org/packages/43/1e/503394cca8978f77ff1a6ac7d3cfa11255cf6e0b92016d37757556c9b99a/tgext.mailer-0.0.2.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "507de9bfaa05e044b0de3b8c5f463b0e", "sha256": "d584d04ba175cacfefb81544eafcf2c1d28e6b8098f269ec0ebec26af584fe2c" }, "downloads": -1, "filename": "tgext.mailer-0.1.0.tar.gz", "has_sig": false, "md5_digest": "507de9bfaa05e044b0de3b8c5f463b0e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14744, "upload_time": "2017-02-05T10:10:20", "url": "https://files.pythonhosted.org/packages/cb/7c/2071eadbfb57fcdf5a26dc772cedb494d882f0bec7120d2b3ed6833a3f6c/tgext.mailer-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "b1a71dfce1c77fc4e7cf6ca8061c8529", "sha256": "ee988bc1bfc5b11507d90414d06302a298f465c9112671717cd2b1a0ae56e124" }, "downloads": -1, "filename": "tgext.mailer-0.2.0.tar.gz", "has_sig": false, "md5_digest": "b1a71dfce1c77fc4e7cf6ca8061c8529", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14739, "upload_time": "2017-02-05T10:22:53", "url": "https://files.pythonhosted.org/packages/52/48/ce4f50b96ef9e9797ebd37f601f3b4a6b2517801be144dea0ee7b4604337/tgext.mailer-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "1c48bf10385d64bf3d601d8699e6d9a3", "sha256": "9f713d567157f3d9a375dd0ce7b962bb67a65933c649570f7b756da6e8b9a8f2" }, "downloads": -1, "filename": "tgext.mailer-0.3.0.tar.gz", "has_sig": false, "md5_digest": "1c48bf10385d64bf3d601d8699e6d9a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12509, "upload_time": "2018-12-25T23:13:16", "url": "https://files.pythonhosted.org/packages/3d/9b/771e4d3245cb131325a327d18769a50201c8090e661e60d7d9d5c275c50d/tgext.mailer-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1c48bf10385d64bf3d601d8699e6d9a3", "sha256": "9f713d567157f3d9a375dd0ce7b962bb67a65933c649570f7b756da6e8b9a8f2" }, "downloads": -1, "filename": "tgext.mailer-0.3.0.tar.gz", "has_sig": false, "md5_digest": "1c48bf10385d64bf3d601d8699e6d9a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12509, "upload_time": "2018-12-25T23:13:16", "url": "https://files.pythonhosted.org/packages/3d/9b/771e4d3245cb131325a327d18769a50201c8090e661e60d7d9d5c275c50d/tgext.mailer-0.3.0.tar.gz" } ] }