{ "info": { "author": "Louis-Dominique Dubeau", "author_email": "ldd@lddubeau.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Framework :: Django :: 2.2", "Intended Audience :: Developers", "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", "Operating System :: POSIX", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Libraries", "Topic :: Utilities" ], "description": "This Django package provides a comment designed to perform **integration tests**\nfor your email setup *after deployment.*\n\n**THIS IS NOT A REPLACEMENT FOR UNIT TESTING YOUR CODE.**\n\nPresumably you already do unit testing of the code that generates emails and use\nthe appropriate setup to avoid actually sending emails to anyone. Perhaps you\nrun automated tests in development that do actually contact a server and send\nemails but the parameters of the test are most likely significantly different\nfrom the production context. Even if your run your tests in a Docker container\nthat mimics your production environment, at the very least, the IP of your test\nserver will be different from the IP used in production.\n\nUltimately none of the above tests are enough to *absolutely* guarantee that\nonce your app runs in production with the production settings your emails are\ngoing to get through without problem. It really depends on how the mail relays\nbetween your server and the final destination are setup. It is really easy to\n*think* your email setup works when in fact it does not. Typically, mail sent to\n``SERVER_EMAIL`` and similar addresses is forwarded elsewhere, forwarding can be\nbroken by SPF or other mechanisms designed to reduce spam. The relay you were\nhoping to use may not allow relaying from your specific address, etc.\n\nThe only way to be sure that the setup is working from end-to-end is to send\nemails *from the production machine and using the production settings*, and\ncheck that they were received.\n\nRequirements\n============\n\nWe support Django from 2.2 onwards and Python from 3.6 onwards.\n\nIf want to *contribute* support for earlier versions of Django or Python, you\nshould open an issue first so that we can discuss your plans. (Do not suggest\nsupport for Python 2.7, Python 3.x versions that are no longer supported, or\nDjango versions that are no longer supported: your suggestion will be rejected.)\n\nManagement Command\n==================\n\nOnce this package is installed and added to your Django APPS settings, you get a\nnew command::\n\n manage.py email_integration_test\n\nThere are no options.\n\nConfiguration\n=============\n\nThis package has a custom setting. Here is an example::\n\n EMAIL_INTEGRATION_TEST = {\n \"IDENTIFIER\": \"my server\",\n \"DESTINATIONS\": [\"foo@example.com\", \"bar@example.com\"],\n \"TIMEOUT\": 5 * 60,\n \"ADDITIONAL_FROM_ADDRESSES\": (\"foo@myserver.com\",),\n \"MAILBOX\": {\n \"TYPE\": \"IMAP4_SSL\",\n \"HOST\": \"example.com\",\n \"PORT\": 1111,\n \"USER\": \"fnord@example.com\",\n \"PASSWORD\": \"password1234\",\n }\n\nAll settings specific to this package belong under the\n``EMAIL_INTEGRATION_TEST`` setting.\n\n``IDENTIFIER`` (mandatory string): a name you choose to identify your server for\nthe sake of email tests.\n\n``DESTINATIONS`` (mandatory iterable of strings): the addresses to which to send\nemails.\n\n``TIMEOUT`` (optional number, default of 5 * 60 seconds): a number in\nseconds. If the test emails do not arrive during this time, the test has failed.\n\n``ADDITIONAL_FROM_ADDRESSES`` (optional iterable of strings, defaults to an\nempty iterable): use this setting to specify other addresses to test *sending\nfrom* in addition to sending from ``SERVER_EMAIL`` and\n``DEFAULT_FROM_EMAIL``. (Why this setting? It is possible to configure mail\nrelays to accept relaying *from* some addresses but not other addresses. So for\nsome use-case scenarios, it is useful to have the capability to test from more\nthan ``SERVER_EMAIL`` and ``DEFAULT_FROM_EMAIL``.\n\n``MAILBOX`` (mandatory dictionary): specifies the mailbox to use to check that\nthe emails were correctly sent. This mailbox *must* be able to read the emails\nsent to at least one of the addresses in ``DESTINATIONS``. It contains the\nfollowing options:\n\n* ``TYPE`` (mandatory string): the type of mailbox. Currently only\n ``\"IMAP4_SSL\"`` is supported.\n\n* ``HOST`` (mandatory string): the host to connect to.\n\n* ``PORT`` (optional number): the port to use to connect to ``HOST``. If blank,\n the default port for ``TYPE`` is used.\n\n* ``USER`` (mandatory string): the user name to use to log in.\n\n* ``PASSWORD`` (mandatory string): the password for ``USER``.\n\nYour email backend must be configured so that ``django.core.mail.send_mail``\nworks. How to do this depends on which backend you use.\n\nHow it works\n============\n\nWhen you run ``email_integration_test``, then for each unique email address\n``address`` in the tuple made from ``SERVER_EMAIL``, ``DEFAULT_FROM_EMAIL`` and\nthe addresses in ``ADDITIONAL_FROM_ADDRESSES``:\n\n * send an email from ``address`` to ``DESTINATIONS`` with the subject::\n\n Server {IDENTIFIER} is testing sending to {address} at {now} ({uid})\n\n where ``IDENTIFIER`` and ``address`` are the variables defined above, ``now``\n is the time at which we started sending emails and ``{uid}`` is a unique\n identifier associated with ``address``.\n\nThen the tool polls the mailbox specified in ``MAILBOX`` for evidence that the\nemails arrived at their destination. They must arrive within ``TIMEOUT`` for the\ntest to be successful.\n\nPick your mail provider carefully\n=================================\n\nThis is true both in production and for testing this code. Some mail providers\nimpose restrictions on what they accept.\n\nExample 1: GMail does not allow using *authenticated* SMTP access to send emails\nwith a ``From:`` address which is different from the address of the account used\nfor logging into the SMTP server. If you have the account ``foo@gmail.com`` and\ntry to send emails as if they were from ``foo@example.com``, your emails *will*\ngo through but they'll be from ``foo@gmail.com``. The explanation is that they\ndo this to prevent spam, but the fit between this objective and the means to get\nthere is extremely loose. Since the SMTP access is authenticated, Google *would*\nhave the capability to deal with spammers. They just don't want that burden so\nthey prevent the ability to send emails from other addresses. (There's a way to\nget Gmail to allow you to select an email address that you prove you control,\nbut I've got no evidence that this also works for SMTP accesses. Besides this\nmethod requires giving Google your user name and password into another mail\nserver. I don't trust Google that much.)\n\nThis makes GMail a poor candidate for running the test suite (and probably\nproduction but you may have a scenario where it makes sense to use it in\nproduction).\n\nContributing\n============\n\nOnce you've cloned the repo, create a new ``./secrets.py`` with appropriate\nvalues. Running the test suite requires real access to a server providing SMTP\nand IMAP 4 interfaces. *You* must pick a server *you* have access to.\n\nTests can be run with::\n\n $ make dev-venv\n $ make test\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lddubeau/django-email-integration-test", "keywords": "Django", "license": "MPL 2.0", "maintainer": "", "maintainer_email": "", "name": "django-email-integration-test", "package_url": "https://pypi.org/project/django-email-integration-test/", "platform": "", "project_url": "https://pypi.org/project/django-email-integration-test/", "project_urls": { "Homepage": "https://github.com/lddubeau/django-email-integration-test" }, "release_url": "https://pypi.org/project/django-email-integration-test/0.1.0/", "requires_dist": null, "requires_python": "", "summary": "Email integration test for Django.", "version": "0.1.0" }, "last_serial": 5914528, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5a05ec15e18cdf8644bb17beae7c6728", "sha256": "546e3e68c3356cf52bfcb2c58aae350b763668e1fb39d464d7f6cb8dece9cfde" }, "downloads": -1, "filename": "django-email-integration-test-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5a05ec15e18cdf8644bb17beae7c6728", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7107, "upload_time": "2019-10-01T19:59:49", "url": "https://files.pythonhosted.org/packages/b6/6c/680728bd2c8066876f91bdbaf55dabe630c35e297241a8bd3f40bc77612b/django-email-integration-test-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5a05ec15e18cdf8644bb17beae7c6728", "sha256": "546e3e68c3356cf52bfcb2c58aae350b763668e1fb39d464d7f6cb8dece9cfde" }, "downloads": -1, "filename": "django-email-integration-test-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5a05ec15e18cdf8644bb17beae7c6728", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7107, "upload_time": "2019-10-01T19:59:49", "url": "https://files.pythonhosted.org/packages/b6/6c/680728bd2c8066876f91bdbaf55dabe630c35e297241a8bd3f40bc77612b/django-email-integration-test-0.1.0.tar.gz" } ] }