Code Monkey home page Code Monkey logo

django-mailer's Introduction

Django Mailer

django-mailer

django-mailer is a reusable Django app for queuing the sending of email. It works by storing email in the database for later sending.

Keep in mind that file attachments are also temporarily stored in the database, which means if you are sending files larger than several hundred KB in size, you are likely to run into database limitations on how large your query can be. If this happens, you'll either need to fall back to using Django's default mail backend, or increase your database limits (a procedure that depends on which database you are using).

django-mailer was developed as part of the Pinax ecosystem but is just a Django app and can be used independently of other Pinax apps.

Requirements

  • Django >= 1.11
  • Databases: django-mailer supports all databases that Django supports, with the following notes:
    • SQLite: you may experience 'database is locked' errors if the send_mail command runs when anything else is attempting to put items on the queue. For this reason SQLite is not recommended for use with django-mailer.

Getting Started

Simple usage instructions:

In settings.py:

INSTALLED_APPS = [
    ...
    "mailer",
    ...
]

EMAIL_BACKEND = "mailer.backend.DbBackend"

Run database migrations to set up the needed database tables.

Then send email in the normal way, as per the Django email docs, and they will be added to the queue.

To actually send the messages on the queue, add this to a cron job file or equivalent:

*       * * * * (/path/to/your/python /path/to/your/manage.py send_mail >> ~/cron_mail.log 2>&1)
0,20,40 * * * * (/path/to/your/python /path/to/your/manage.py retry_deferred >> ~/cron_mail_deferred.log 2>&1)

To prevent from the database filling up with the message log, you should clean it up every once in a while.

To remove successful log entries older than a week, add this to a cron job file or equivalent:

0 0 * * * (/path/to/your/python /path/to/your/manage.py purge_mail_log 7 >> ~/cron_mail_purge.log 2>&1)

Use the -r failure option to remove only failed log entries instead, or -r all to remove them all.

Documentation and support

See usage.rst in the docs for more advanced use cases. The Pinax documentation is available at http://pinaxproject.com/pinax/.

This is an Open Source project maintained by volunteers, and outside this documentation the maintainers do not offer other support. For cases where you have found a bug you can file a GitHub issue. In case of any questions we recommend you join the Pinax Slack team and ping the Pinax team there instead of creating an issue on GitHub. You may also be able to get help on other programming sites like Stack Overflow.

Contribute

See CONTRIBUTING.rst for information about contributing patches to django-mailer.

See this blog post including a video, or our How to Contribute section for an overview on how contributing to Pinax works. For concrete contribution ideas, please see our Ways to Contribute/What We Need Help With section.

We also highly recommend reading our Open Source and Self-Care blog post.

Code of Conduct

In order to foster a kind, inclusive, and harassment-free community, the Pinax Project has a code of conduct. We ask you to treat everyone as a smart human programmer that shares an interest in Python, Django, and Pinax with you.

Pinax Project Blog and Twitter

For updates and news regarding the Pinax Project, please follow us on Twitter at @pinaxproject and check out our blog.

django-mailer's People

Contributors

alenalato avatar alepane21 avatar alex avatar alir3z4 avatar andybak avatar bashu avatar benkonrath avatar bmihelac avatar brosner avatar davidszotten avatar dougn avatar empty avatar felixxm avatar frankier avatar git2samus avatar grzn avatar hartwork avatar jacinda avatar jezdez avatar jtauber avatar julienc91 avatar pakal avatar paltman avatar pawl avatar spookylukey avatar srtab avatar terminator14 avatar tim-schilling avatar unode avatar zerok avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.