Closed waqasraz closed 8 years ago
Also if i try to add image ta li
send_db_mail( 'customer', '', { 'image': u"< src=link />" }, use_celery=False, )
i get escape sting < img src=link >
dbmail/backends/mail.py
. For html messages we are using clean_html for text part https://github.com/LPgenerator/django-db-mailer/blob/development/dbmail/backends/mail.py#L163On my tests all is working properly on master branch.
After few days of lookup i realize the problem was with premailer. If i don't have premailer install everything work fine.
:)
Anyway sometimes I have a need to put some urls in my template, i.e. <a href="{{sites.main.url}}">{{sites.main.name}}</a>
and premailer breaks a template var repr to %7b%7bsites.main.url%7d%7d
The stupid fast hack looks like:
# -*- coding: utf-8 -*-
from django.db.models.signals import pre_save
from django.dispatch import receiver
from dbmail.models import MailTemplate
@receiver(pre_save, sender=MailTemplate, dispatch_uid='mailtemplate_pre_save')
def mailtemplate_pre_save(sender, instance: MailTemplate, **kwargs):
instance.message = instance.message.replace('%7B%7B', '{{')
instance.message = instance.message.replace('%7b%7b', '{{')
instance.message = instance.message.replace('%7D%7D', '}}')
instance.message = instance.message.replace('%7d%7d', '}}')
But imho the the right way looks like addition message {pre,post}processor pipeline support.
that a premailer
problems. not a dbmail.
When using Ck-editor if you define a template tage for image_url as <img src={{ imageurl }} Ck editor encode them to %7B%7B%20image_url%20%7D%7D and is not recognized by db-mailer while sending email. Any solution for this?