本文整理匯總了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)