mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
@@ -9,7 +9,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.db.models.manager import Manager
|
||||
from django.utils.encoding import python_2_unicode_compatible, smart_text
|
||||
from django.utils.encoding import smart_text, force_text
|
||||
from django.utils.translation import ugettext as _, ugettext_lazy
|
||||
|
||||
from modoboa.core.models import User
|
||||
@@ -164,7 +164,7 @@ class Mailbox(mixins.MessageLimitMixin, AdminObject):
|
||||
if code:
|
||||
raise lib_exceptions.InternalError(
|
||||
_("Failed to retrieve mailbox location (%s)") % output)
|
||||
self.__mail_home = output.strip()
|
||||
self.__mail_home = force_text(output.strip())
|
||||
return self.__mail_home
|
||||
|
||||
@property
|
||||
@@ -357,7 +357,6 @@ class Mailbox(mixins.MessageLimitMixin, AdminObject):
|
||||
reversion.register(Mailbox)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SenderAddress(models.Model):
|
||||
"""Extra sender address for Mailbox."""
|
||||
|
||||
|
||||
@@ -11,11 +11,13 @@ import lxml.html
|
||||
from lxml.html import defs
|
||||
from lxml.html.clean import Cleaner
|
||||
|
||||
from django.core.mail import EmailMessage
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.encoding import smart_str, smart_text
|
||||
from django.utils.html import conditional_escape, escape
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from modoboa.core import models as core_models
|
||||
from modoboa.lib import u2u_decode
|
||||
from modoboa.lib.exceptions import InternalError
|
||||
|
||||
@@ -467,3 +469,16 @@ To: %s
|
||||
fp.close()
|
||||
|
||||
return _sendmail(sender, rcpt, content)
|
||||
|
||||
|
||||
def send_notification(recipient, subject, tpl, sender=None, **kwargs):
|
||||
"""Send notification by email."""
|
||||
if not sender:
|
||||
local_config = (
|
||||
core_models.LocalConfig.objects.select_related("site").first())
|
||||
sender = local_config.parameters.get_value("sender_address")
|
||||
content = render_to_string(tpl, kwargs)
|
||||
msg = EmailMessage(
|
||||
subject, content.strip(), sender, [recipient],
|
||||
)
|
||||
msg.send()
|
||||
|
||||
Reference in New Issue
Block a user