Code Monkey home page Code Monkey logo

django-send-email's Introduction

Email Command for Django

This app provides a simple management command for sending emails using your Django settings from the command line.

Install

Pull down the app:

$ pip install django-send-email

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
  ...
  'django_send_email'
)

Sending Emails

django-send-email provides a management command named send_email_message to send emails from the command line.

$ django-admin.py send_email_message subject message [email protected] [email protected]

Subject, message and at least one recipient are required. You can pass ADMINS or MANAGERS as any one of the recipients and django-send-email will fetch the recipients from the proper Django setting.

$ django-admin.py send_email_message subject message MANAGERS --bcc=ADMINS

You can also pass a filename as the message argument and django-send-email will use the file contents at the body of the email.

$ django-admin.py send_email_message subject /path/to/message.txt [email protected] [email protected]

Alternatively you can use - as the message argument to read from standard input.

$ django-admin.py send_email_message subject - [email protected] [email protected] < /path/to/message.txt
$ echo "some message text" | django-admin.py send_email_message subject - [email protected] [email protected]

Full Usage

Usage: manage.py send_email_message [options] <subject> <message or file or "-"> <recipient1>...<recipientN>

Sends an email to the specified email addresses.
Message can be a string, filename or "-" to read from stdin.

Options:
  -v VERBOSITY, --verbosity=VERBOSITY
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings=SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath=PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Print traceback on exception
  --noinput             Tells Django to NOT prompt the user for input of any
                        kind.
  -f FROM_EMAIL, --from=FROM_EMAIL
                        Email address to use to send emails from. Defaults to
                        use settings.DEFAULT_FROM_EMAIL
  -r, --raise-error     Exceptions during the email sending process will be
                        raised. Default to failing silently
  -n, --noprefix        Disables email subject prefix. Default behavior is to
                        prepend settings.EMAIL_SUBJECT_PREFIX
  -b BCC, --bcc=BCC     Comma separated list of email addresses for BCC
  -c CC, --cc=CC        Comma separated list of email addresses for CC
  --version             show program's version number and exit
  -h, --help            show this help message and exit

Testing

Running the unittests is as simple as testing any other Django app

django-admin.py test django_send_email

To test the command on a development SMTP server, you can run the debug SMTP server from the smtp library.

$ python -m smtpd -n -c DebuggingServer localhost:1025

Just make sure that Django is configured correctly to point at localhost:1025

django-send-email's People

Contributors

justquick avatar twidi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-send-email's Issues

Add support for HTML email

Hi,

It would be nice to add a "--html" command line option, which would send the message body as an HTML part. In such a case, the plain text part can be some placeholder text such as "This message must be viewed in an HTML-capable mail client".

Thanks!

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.