本文整理汇总了Python中django.core.mail.backends.base.BaseEmailBackend方法的典型用法代码示例。如果您正苦于以下问题:Python base.BaseEmailBackend方法的具体用法?Python base.BaseEmailBackend怎么用?Python base.BaseEmailBackend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.core.mail.backends.base
的用法示例。
在下文中一共展示了base.BaseEmailBackend方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_connection_config
# 需要导入模块: from django.core.mail.backends import base [as 别名]
# 或者: from django.core.mail.backends.base import BaseEmailBackend [as 别名]
def make_connection_config() -> BaseEmailBackend:
from apps.notifications.app_vars import APP_VAR_EMAIL_HOST, APP_VAR_EMAIL_USE_TLS, \
APP_VAR_EMAIL_PORT, APP_VAR_EMAIL_HOST_USER, APP_VAR_EMAIL_HOST_PASSWORD
from apps.common.models import AppVar
cache_vars = AppVar.get_values_by_category(AppVar.MAIL_CATEGORY)
from apps.notifications.app_vars import APP_VAR_EMAIL_BACKEND
backend_class = APP_VAR_EMAIL_BACKEND.get_cached_value(cache_vars)
ctor = MailServerConfig.import_class(backend_class)
return ctor(host=APP_VAR_EMAIL_HOST.get_cached_value(cache_vars),
port=APP_VAR_EMAIL_PORT.get_cached_value(cache_vars),
username=APP_VAR_EMAIL_HOST_USER.get_cached_value(cache_vars),
password=APP_VAR_EMAIL_HOST_PASSWORD.get_cached_value(cache_vars),
use_tls=APP_VAR_EMAIL_USE_TLS.get_cached_value(cache_vars),
fail_silently=False)
示例2: get_context_data
# 需要导入模块: from django.core.mail.backends import base [as 别名]
# 或者: from django.core.mail.backends.base import BaseEmailBackend [as 别名]
def get_context_data(self, **kwargs):
"""
Use this view's BaseEmailBackend implementation to do a dry-run of
sending the generated messages, and return a preview of the messages
that would be sent.
"""
self.messages = []
self.generate_messages(current_round=self.get_round(), connection=self)
# Find all URLs in all messages by asking Django's urlize function to
# mark up URL-like text as HTML and then looking for the HTML that
# urlize generated.
urlize_re = re.compile(r'<a href="(.*?)"')
urls = set()
for message in self.messages:
for url in urlize_re.finditer(urlize(message.body)):
urls.add(url.group(1))
context = super(SendEmailView, self).get_context_data(**kwargs)
context['messages'] = self.messages
context['urls'] = sorted(urls)
return context
示例3: send_messages
# 需要导入模块: from django.core.mail.backends import base [as 别名]
# 或者: from django.core.mail.backends.base import BaseEmailBackend [as 别名]
def send_messages(self, messages):
"""
Implementation of BaseEmailBackend that just saves the generated
messages on self, so get_context_data can dig them back out again.
"""
self.messages.extend(messages)
return len(messages)