Skip to content

Email sending in Django environment

Igor edited this page Mar 30, 2017 · 1 revision

The problem

There is regular way to send an email in Django framework.

The credentials of sender are written in settings.py. The list of recipients by proposed design should be hard-coded. The problem touches the concept of open source programming. Mainly, we want to publish the Django project to github or any other sharing platform as it is. I.e. the published code should include settings.py.

Solutions

  1. It's possible to create a table in the DB (in models.py) for emailing details. Pros: Then the data can be kept or retrieved pretty safe and integrated. Cons: Significant particular programming effort is required. Maintenance is required.
  2. It is (maybe) possible to import or read the external data during Django load. I didn't find elegant way to do so.
  3. Keep sensitive data in importable file. Do not commit it to git, do not publish it. For the documentation publish sample file with junk data. Import the sensitive data file during runtime. Call regular python emailing function. The implementation is:

Clone this wiki locally