GithubHelp home page GithubHelp logo

artemrizhov / django-mail-templated Goto Github PK

View Code? Open in Web Editor NEW
154.0 154.0 27.0 126 KB

Send emails using Django template system

License: MIT License

Python 85.28% HTML 0.93% Smarty 4.65% Shell 9.13%
django email mail python templates

django-mail-templated's People

Contributors

almost avatar arjandepooter avatar artemrizhov avatar feskovio avatar kminkov avatar streeter avatar suciu0313 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

django-mail-templated's Issues

Can't send html, only plain works.

It seems when i load a template with only {% block html %}<strong>Text</strong>{% endblock %} mail is sent as a text/plain message. Anyone having this issue?

Full template looks like this

{% extends 'mail_templated/base.tpl' %}

{% block subject %}
Din bruger på Klinikker.dk
{% endblock %}

{% block html %}
    <h1>Hello there</h1>
{% endblock %}

When create mesage - i take mistake. Django 1.11.7, Python 3.5

When i create message, i take mistake:
AttributeError at /
'NoneType' object has no attribute 'splitlines'
Request Method: POST
Request URL: http://127.0.0.1:8080/
Django Version: 1.11.7
Exception Type: AttributeError
Exception Value:
'NoneType' object has no attribute 'splitlines'
Exception Location: /var/www/lf/lib/python3.5/site-packages/django/core/mail/message.py in set_payload, line 224
Python Executable: /var/www/lf/bin/python
Python Version: 3.5.3
Python Path:
['/var/www/lf/lFD',
'/usr/lib/python35.zip',
'/usr/lib/python3.5',
'/usr/lib/python3.5/plat-x86_64-linux-gnu',
'/usr/lib/python3.5/lib-dynload',
'/var/www/lf/lib/python3.5/site-packages',
I take settings from docs.
Is it incompatibility or Did i mistake anywhere?

Breaks for some template inheritance / extends

Hey, had the same issue with my lib (vintasoftware/django-templated-email#3) with a caveated fix here - https://github.com/bradwhittington/django-templated-email/blob/867ef61693d02a39ca902a30e66d5dd7dd941cda/templated_email/utils.py

It breaks when you don't have blocks for subject/body/etc. in the template you render, but do have them in the template you extend

My solution is a messy hack, but after diving into the template code I couldn't find a better solution. Would love to see a neater, more comprehensive one (this breaks for {{block.super}})

Iterate array

Hello, is there a way i can iterate a list in my html email template?

i tried creating it before passing to the context as well with no luck:

        not_in_db_html = "<ul>"
        for db in sorted(not_in_db):
            not_in_db_html += "<li>" + db + "</li> "

        not_in_db_html += "</ul>"

it displays as a string in my email

Mandrill API response 500: No such template [RESOLVED]

Hi,

I'm having difficulties using django-mail-templated. When I tried to send email through form, I get this error :

(I'm pretty sure the template is exsist in there. I'm using Djrill plugin and Django 1.9)

MandrillAPIError at /order/

Sending a message to [email protected] from [email protected]
Mandrill API response 500:
{
  "status": "error", 
  "message": "No such template \"email/order_email.html\"", 
  "code": 5, 
  "name": "Unknown_Template"
}

This is my views.py

from mail_templated import send_mail

@login_required
def order_form(request):
    if request.method == "POST":
        form = OrderForm(request.POST, request.FILES)
        if form.is_valid():
            order = form.save(commit=False)
            order.tanggal_order = datetime.datetime.now()
            order.save()
            from_email = '[email protected]'
            send_mail('email/order_email.html', {'order': order}, from_email, [order.email])
            return render(request, 'order_app/order_success.html')
    else:
        form = OrderForm()
    return render(request, 'order_app/order_form.html', {'form': form})

My order_email.html template:

{% extends "email/base.html" %}

{% block subject %}
Hello {{ order.nama }}
{% endblock %}

{% block html %}
This is an <strong>{{ order.id }}</strong> message.
{% endblock %}

My app directory tree :

alt text

Thank you in advance for any help you can provide :)

Regards,

#egg=django-mail-templated WARNING

When I install this package via pip, I am getting this warning.

WARNING: Generating metadata for package django-mail-templated produced metadata for project name dabapps-django-mail-templated. Fix your #egg=django-mail-templated fragments.

Please fix this.

RemovedInDjango110Warning when render with Context

Hello, my django version is 1.9.2, when I send_mail with mail_templated has warning like this:

WARNING:py.warnings::/usr/local/lib/python2.7/dist-packages/mail_templated/message.py:174: RemovedInDjango110Warning: render() must be called with a dict, not a Context.
  result = self.template.render(context)

I know this does not affect to use, but if replace Context with dict is easy, I think it is a good idea for compatibility.

I love this package, thank you ~

Incorrect super usage

Hi,
I've noticed that you use super incorrectly:

class EmailMessage(mail.EmailMultiAlternatives):
    ...
    def __init__(self, template_name, context, *args, **kwargs):
        ...
        # super(mail.EmailMultiAlternatives, self).__init__(*args, **kwargs) # incorrect
        super(EmailMessage, self).__init__(*args, **kwargs) # correct

BTW great lib, keep on working ;).

Raise nice error if not inheriting from the base template

If I forget to inherit from the base template provided with django-mail-templated, I'll get some cryptic error like this:

Traceback (most recent call last):
  File "mail_templated/message.py", line 227, in send
    return super(EmailMessage, self).send(*args, **kwargs)
  File "django/core/mail/message.py", line 292, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "django/core/mail/backends/locmem.py", line 26, in send_messages
    message.message()
  File "django/core/mail/message.py", line 255, in message
    msg = SafeMIMEText(self.body, self.content_subtype, encoding)
  File "django/core/mail/message.py", line 171, in __init__
    MIMEText.__init__(self, _text, _subtype, None)
  File "email/mime/text.py", line 34, in __init__
    _text.encode('us-ascii')
AttributeError: 'NoneType' object has no attribute 'encode'

This should be caught earlier if possible and turned into a nice error message.

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.