Python django.core.mail.backends.base.BaseEmailBackend() Examples
The following are 3
code examples of django.core.mail.backends.base.BaseEmailBackend().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.core.mail.backends.base
, or try the search function
.
Example #1
Source File: mail_server_config.py From lexpredict-contraxsuite with GNU Affero General Public License v3.0 | 6 votes |
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)
Example #2
Source File: dashboard.py From website with GNU General Public License v3.0 | 6 votes |
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
Example #3
Source File: dashboard.py From website with GNU General Public License v3.0 | 5 votes |
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)