{ "info": { "author": "Openlabs Technologies and Consulting (P) Ltd.", "author_email": "info@openlabs.co.in", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Plugins", "Framework :: Tryton", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Office/Business" ], "description": "Trytond Mail\n=============\n\n.. image:: https://secure.travis-ci.org/openlabs/trytond-mail.png?branch=develop\n :target: https://travis-ci.org/openlabs/trytond-mail\n\n.. image:: https://coveralls.io/repos/openlabs/trytond-mail/badge.png\n :target: https://coveralls.io/r/openlabs/trytond-mail\n\nOne does not simply send emails!\n--------------------------------\n\nSending emails from tryton modules is a frequent requirement. This module\nmakes it easier by providing a convenient and consistent API to generate email\nmessages. In addition, the module gives you a few goodies (template\ninheritance, filters) that come in handy when sending emails.\n\nInstallation\n------------\n\nThe module can be installed from pypi\n\n.. code-block:: sh\n\n pip install openlabs_mail\n\n.. tip::\n\n Remember to install a version compatible with your version of trytond.\n\nAlternatively the module could be added as a dependency to your module\n\n.. code-block:: python\n\n # your_module/tryton.cfg\n [tryton]\n ...\n depends:\n ...\n mail\n ...\n\nSee `sale-confirmation-email module `_\nfor practical example.\n\nIf you use setup.py to install modules, remember to set the prefix as\nopenlabs for the modules. The `setup.py file `_ \nfrom `sale confirmation email module `_ \nis a good example.\n\nQuickstart\n----------\n\nHere is a code example, if you wished to send emails when sale orders are\nconfirmed\n\n.. code-block:: python\n\n def confirm(cls, sales):\n Mail = Pool().get('mail.mail')\n\n # Call super function to confirm\n super(Sale, cls).confirm(sales)\n\n # Send an email for each order\n for sale in sales:\n email_message = Mail.render_email(\n from_email='order-confirmation@mydomain.com',\n to=[sale.party.email],\n subject='Your Order is confirmed',\n text_template='my_module/emails/order-confirmed.txt',\n sale=self, # passed to template context\n )\n # send email_message using your preferred gateway\n\nDetailed Introduction\n---------------------\n\nThe module provides a convenient method named ``render_email`` which returns\na python ``mail.Message`` object which can then be sent using smtpservers.\n\n.. tip::\n\n Sending emails during a transaction could be slow and result in bad\n user experience. Use the \n `email-queue `_ module instead.\n\n\nRendering of templates\n``````````````````````\n\nThe email requires at-least one of either ``html`` or ``text`` templates to be\nspecified. Specifying both is recommended as some email clients prefer to\ndisplay text content when available.\n\nSpecifying both text and html parts\n\n.. code-block:: python\n\n email_message = Mail.render_email(\n from_email='me@mydomain.com',\n to=['you@somewhere.com'],\n subject='A great honking email',\n text_template='my_module/emails/honking-email.txt',\n html_template='my_module/emails/honking-email.html',\n )\n\nThe template name is expected to be in the format:\n`/path/to/email/template`.\n\n.. tip::\n\n Remember to add the folder containing email templates to your data in\n `setup.py` to ensure they are copied to site-packages and distributed\n with your module.\n\nExtending templates (DRY)\n`````````````````````````\n\nEvery business is unique and so should be their emails. You may want to\nadd content to your template, change the design or completely overwrite\nthe email. If your goal is to add (extend) the email, the API allows you\nto do it without repeating yourself.\n\nIn your downstream module, extend the template\n\n.. code-block:: html+jinja\n\n {% extends 'sale-confirmation-email/email//sale-confirmation-html.html' %}\n\n {% block footer %}\n {{ super() }}\n
\n Visit us on facebook\n {% endblock footer %}\n\nIn the above example, the standard template bundled with the \n`sale confirmation email module `_ \nis extended to add a link to the facebook page.\n\nThis pattern is common if you are familiar with the \n`jinja2 `_ templating engine. You can learn more \nabout extending them from `jinja2 docs `_\n\n\nTemplate Filters\n````````````````\n\nVariable within templates can be modified using filters\n\n``{{ name|striptags|title }}`` for example will remove all HTML Tags from the\nname and title-cases it. Filters that accept arguments have parentheses around\nthe arguments, like a function call. This example will join a list by commas: \n``{{ list|join(', ') }}``.\n\nThe `List of Builtin Filters `_ \non Jinja2 documentation describes all the builtin filters. In addition,\nthis module offers the following filters:\n\ndateformat(date, format='medium')\n+++++++++++++++++++++++++++++++++\n\nFormat the date with the current language from the context. For other\npossible formats, refer the \n`babel documentation `_.\n\nExample\n\n.. code-block:: html+jinja\n\n Date\n {{ sale.date|dateformat }}\n\ndatetimeformat(datetime, format)\n++++++++++++++++++++++++++++++++\n\nFormat the datetime with the current language from the context. For other\npossible formats, refer the \n`babel documentation `_.\n\nExample\n\n.. code-block:: html+jinja\n\n Created on {{ sale.create_date|datetimeformat('long') }}\n\ncurrencyformat(amount, currency, format=None)\n+++++++++++++++++++++++++++++++++++++++++++++\n\nReturn formatted currency value. For more formatting information refer\n`babel documentation `_\n\nExample\n\n.. code-block:: html+jinja\n\n Total Value\n {{ sale.total_amount|currencyformat(sale.currency.code) }}\n\n\nto, cc and bcc\n```````````````\n\nSending an email to a certain set of recepients is different from setting\nthe recepient headers on the email. To indicate the recepients, send a\nlist of recepients to the ``to`` argument.\n\nWhile ``cc`` is a commonly set header to indicate the recepients who have been \ncopied the email, setting ``bcc`` would defeat the purpose as the recepients \nwould be disclosed to everyone. Hence ``cc`` is the only other argument\naccepted by the ``render_email`` method. To send a ``bcc``, you could send the\nsame message to the recepient when using the smtpserver to send email.\n\nExample\n\n.. code-block:: python\n\n email_message = Mail.render_email(\n to=['you@somewhere.com', 'youtoo@somewhere.com'],\n cc=['myself@mydomain.com'],\n\n # Usual stuff\n from_email='me@mydomain.com',\n subject='A great honking email',\n text_template='my_module/emails/honking-email.txt',\n )\n \n\nSending attachments\n```````````````````\n\nThe method also accepts an argument ``attachments`` which takes a dictionary\nwhere keys represent the filenames and the values are buffer streams of\nthe content to be attached. If attachment(s) are present, the mail type is\nautomatically changed to ``multipart/mixed``. The attachments should appear\nas downloadable attachments on email clients\n\nExample of sending\n\n.. code-block:: python\n\n # Read a file from filesystem\n order_copy = buffer(open('order_copy.pdf').read())\n\n # From a binary field in tryton\n product_photo = product.image\n\n email_message = Mail.render_email(\n attachments={\n 'order-copy.pdf': order_copy,\n 'product-photo.png': product_photo,\n },\n\n # Other usual stuff\n from_email='me@mydomain.com',\n to=['you@somewhere.com'],\n subject='A great honking email',\n text_template='my_module/emails/honking-email.txt',\n html_template='my_module/emails/honking-email.html',\n )\n\nAuthors and Contributors\n------------------------\n\nThis module was built at `Openlabs `_. \n\nProfessional Support\n--------------------\n\nThis module is professionally supported by `Openlabs `_.\nIf you are looking for on-site teaching or consulting support, contact our\n`sales `_ and `support\n`_ teams.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://www.openlabs.co.in/", "keywords": null, "license": "GPL-3", "maintainer": null, "maintainer_email": null, "name": "openlabs_mail", "package_url": "https://pypi.org/project/openlabs_mail/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/openlabs_mail/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://www.openlabs.co.in/" }, "release_url": "https://pypi.org/project/openlabs_mail/3.4.0.1/", "requires_dist": null, "requires_python": null, "summary": "Trytond Mail module by Openlabs", "version": "3.4.0.1" }, "last_serial": 1698204, "releases": { "3.2.0.1": [ { "comment_text": "", "digests": { "md5": "92064cb413b365bc7653e7b28cd43481", "sha256": "245722a87613c3eae256f8f91ab21f1f18fd20656b4c2c2c963688a430b52594" }, "downloads": -1, "filename": "openlabs_mail-3.2.0.1.tar.gz", "has_sig": false, "md5_digest": "92064cb413b365bc7653e7b28cd43481", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6684, "upload_time": "2015-01-01T10:14:26", "url": "https://files.pythonhosted.org/packages/c1/cc/1d6595e377cfae7aa85e5864e731f48c077b9bb65c989226f7bce231930b/openlabs_mail-3.2.0.1.tar.gz" } ], "3.2.0.2": [ { "comment_text": "", "digests": { "md5": "9ae41f7d8d9ffe3edc97b1c380d856b8", "sha256": "30a722229b33c034c26989c0ac8d9a4214a16095694df7436a504598bf6f201a" }, "downloads": -1, "filename": "openlabs_mail-3.2.0.2.tar.gz", "has_sig": false, "md5_digest": "9ae41f7d8d9ffe3edc97b1c380d856b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6725, "upload_time": "2015-01-02T11:56:05", "url": "https://files.pythonhosted.org/packages/af/1f/b73e199fc70502aac47844346f56c8f6a44a6d6634615184eca476c8d6b4/openlabs_mail-3.2.0.2.tar.gz" } ], "3.4.0.1": [ { "comment_text": "", "digests": { "md5": "6868add05e8165e889acda42ee6acd36", "sha256": "f72fba5df3667ee1b4d58cfd2b7ab83ae5ef4d648a3fbcda0fdb5e1720937657" }, "downloads": -1, "filename": "openlabs_mail-3.4.0.1.tar.gz", "has_sig": false, "md5_digest": "6868add05e8165e889acda42ee6acd36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9504, "upload_time": "2015-02-04T15:09:49", "url": "https://files.pythonhosted.org/packages/4b/09/38c38a411a69eb15e41ef2e7b3ad89469df503b3fee6f371c7056b4932bd/openlabs_mail-3.4.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6868add05e8165e889acda42ee6acd36", "sha256": "f72fba5df3667ee1b4d58cfd2b7ab83ae5ef4d648a3fbcda0fdb5e1720937657" }, "downloads": -1, "filename": "openlabs_mail-3.4.0.1.tar.gz", "has_sig": false, "md5_digest": "6868add05e8165e889acda42ee6acd36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9504, "upload_time": "2015-02-04T15:09:49", "url": "https://files.pythonhosted.org/packages/4b/09/38c38a411a69eb15e41ef2e7b3ad89469df503b3fee6f371c7056b4932bd/openlabs_mail-3.4.0.1.tar.gz" } ] }