當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.EMAIL_SUBJECT_PREFIX屬性代碼示例

本文整理匯總了Python中django.conf.settings.EMAIL_SUBJECT_PREFIX屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.EMAIL_SUBJECT_PREFIX屬性的具體用法?Python settings.EMAIL_SUBJECT_PREFIX怎麽用?Python settings.EMAIL_SUBJECT_PREFIX使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在django.conf.settings的用法示例。


在下文中一共展示了settings.EMAIL_SUBJECT_PREFIX屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_send_expiration_mails

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def test_send_expiration_mails(mailoutbox, mocker, now, cluster_factory):
    cluster = cluster_factory(
        expires_at=now + timedelta(minutes=59),  # 1 hours is the cut-off
        most_recent_status=models.Cluster.STATUS_WAITING,
    )
    assert len(mailoutbox) == 0
    tasks.send_expiration_mails()
    assert len(mailoutbox) == 1
    message = mailoutbox[0]
    assert message.subject == (
        "%sCluster %s is expiring soon!"
        % (settings.EMAIL_SUBJECT_PREFIX, cluster.identifier)
    )
    assert message.from_email == settings.DEFAULT_FROM_EMAIL
    assert list(message.to) == [cluster.created_by.email]
    cluster.refresh_from_db()
    assert cluster.expiration_mail_sent 
開發者ID:mozilla,項目名稱:telemetry-analysis-service,代碼行數:19,代碼來源:test_tasks.py

示例2: _send_invitation_mail

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def _send_invitation_mail(request, invitation, subject, template_name):
    if not invitation.invitee.email:
        return
    old_lang = translation.get_language()
    translation.activate(invitation.invitee.language)
    template = loader.get_template('groups/mail_{0}.txt'.format(template_name))
    message = template.render({
        'invitation': invitation,
        'site': get_current_site(request)
    })
    translation.activate(old_lang)
    send_mail(settings.EMAIL_SUBJECT_PREFIX + subject,
              message,
              settings.DEFAULT_FROM_EMAIL,
              [invitation.invitee.email],
              fail_silently=True) 
開發者ID:fsinfuhh,項目名稱:Bitpoll,代碼行數:18,代碼來源:views.py

示例3: send_mail_async

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def send_mail_async(*args, **kwargs):
    """ Using celery to send email async

    You can use it as django send_mail function

    Example:
    send_mail_sync.delay(subject, message, from_mail, recipient_list, fail_silently=False, html_message=None)

    Also you can ignore the from_mail, unlike django send_mail, from_email is not a require args:

    Example:
    send_mail_sync.delay(subject, message, recipient_list, fail_silently=False, html_message=None)
    """
    if len(args) == 3:
        args = list(args)
        args[0] = settings.EMAIL_SUBJECT_PREFIX + args[0]
        args.insert(2, settings.EMAIL_HOST_USER)
        args = tuple(args)

    try:
        send_mail(*args, **kwargs)
    except Exception as e:
        logger.error("Sending mail error: {}".format(e)) 
開發者ID:getway,項目名稱:diting,代碼行數:25,代碼來源:tasks.py

示例4: test_send_mail_to_case_author

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def test_send_mail_to_case_author(self, send_mail):
        expected_subject = _('DELETED: TestCase #%(pk)d - %(summary)s') % {
            'pk': self.case.pk,
            'summary': self.case.summary
        }
        expected_body = render_to_string('email/post_case_delete/email.txt', {'case': self.case})
        recipients = get_case_notification_recipients(self.case)

        self.case.delete()

        # Verify notification mail
        send_mail.assert_called_once_with(settings.EMAIL_SUBJECT_PREFIX + expected_subject,
                                          expected_body,
                                          settings.DEFAULT_FROM_EMAIL,
                                          recipients,
                                          fail_silently=False) 
開發者ID:kiwitcms,項目名稱:Kiwi,代碼行數:18,代碼來源:test_models.py

示例5: test_notify_assignee_on_bug_creation

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def test_notify_assignee_on_bug_creation(self, send_mail):
        assignee = UserFactory()
        bug = BugFactory(assignee=assignee)

        expected_subject = _('NEW: Bug #%(pk)d - %(summary)s') % {'pk': bug.pk,
                                                                  'summary': bug.summary}
        expected_body = render_to_string('email/post_bug_save/email.txt', {'bug': bug})
        expected_recipients = [assignee.email]

        send_mail.assert_called_once_with(
            settings.EMAIL_SUBJECT_PREFIX + expected_subject,
            expected_body,
            settings.DEFAULT_FROM_EMAIL,
            expected_recipients,
            fail_silently=False
        )
        self.assertTrue(send_mail.called) 
開發者ID:kiwitcms,項目名稱:Kiwi,代碼行數:19,代碼來源:test_models.py

示例6: mail_comment

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def mail_comment(request, comment_id):
    from yats.models import tickets_comments
    com = tickets_comments.objects.get(pk=comment_id)
    ticket_id = com.ticket_id
    int_rcpt, pub_rcpt = get_mail_recipient_list(request, ticket_id)

    tic = get_ticket_model().objects.get(pk=ticket_id)

    if len(int_rcpt) > 0:
        try:
            send_mail('%s#%s: %s - %s' % (settings.EMAIL_SUBJECT_PREFIX, tic.id, _('new comment'), tic.caption), '%s\n\n%s' % (com.comment, get_ticket_url(request, ticket_id)), settings.SERVER_EMAIL, int_rcpt, False)
        except Exception:
            messages.add_message(request, messages.ERROR, _('mail not send: %s') % sys.exc_info()[1])

    if len(pub_rcpt) > 0:
        try:
            send_mail('%s#%s: %s - %s' % (settings.EMAIL_SUBJECT_PREFIX, tic.id, _('new comment'), tic.caption), '%s\n\n%s' % (com.comment, get_ticket_url(request, ticket_id, for_customer=True)), settings.SERVER_EMAIL, pub_rcpt, False)
        except Exception:
            messages.add_message(request, messages.ERROR, _('mail not send: %s') % sys.exc_info()[1]) 
開發者ID:mediafactory,項目名稱:yats,代碼行數:21,代碼來源:shortcuts.py

示例7: mail_admins

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:13,代碼來源:__init__.py

示例8: mail_managers

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def mail_managers(subject, message, fail_silently=False, connection=None,
                  html_message=None):
    """Sends a message to the managers, as defined by the MANAGERS setting."""
    if not settings.MANAGERS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.MANAGERS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:13,代碼來源:__init__.py

示例9: test_extended_cluster_resends_expiration_mail

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def test_extended_cluster_resends_expiration_mail(mailoutbox, mocker, one_hour_ago, cluster_factory):
    cluster = cluster_factory(
        expires_at=one_hour_ago,
        most_recent_status=models.Cluster.STATUS_WAITING,
    )

    # Send first expiration email
    assert len(mailoutbox) == 0
    tasks.send_expiration_mails()
    assert len(mailoutbox) == 1
    message = mailoutbox[0]
    assert message.subject == (
        '%sCluster %s is expiring soon!' %
        (settings.EMAIL_SUBJECT_PREFIX, cluster.identifier)
    )
    assert message.from_email == settings.DEFAULT_FROM_EMAIL
    assert list(message.to) == [cluster.created_by.email]
    cluster.refresh_from_db()
    assert cluster.expiration_mail_sent

    # Extend cluster lifetime
    cluster.extend(1)
    cluster.refresh_from_db()
    assert cluster.expiration_mail_sent is False

    # Send second expiration email
    tasks.send_expiration_mails()
    assert len(mailoutbox) == 2
    message = mailoutbox[1]
    assert message.subject == (
        '%sCluster %s is expiring soon!' %
        (settings.EMAIL_SUBJECT_PREFIX, cluster.identifier)
    )
    assert message.from_email == settings.DEFAULT_FROM_EMAIL
    assert list(message.to) == [cluster.created_by.email]
    cluster.refresh_from_db()
    assert cluster.expiration_mail_sent 
開發者ID:mozilla,項目名稱:telemetry-analysis-service,代碼行數:39,代碼來源:test_tasks.py

示例10: test_send_run_alert_mails

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def test_send_run_alert_mails(
    client, mailoutbox, mocker, spark_job, sparkjob_provisioner_mocks
):
    mocker.patch(
        "atmo.clusters.provisioners.ClusterProvisioner.info",
        return_value={
            "creation_datetime": timezone.now(),
            "ready_datetime": None,
            "end_datetime": None,
            "state": Cluster.STATUS_TERMINATED_WITH_ERRORS,
            "state_change_reason_code": Cluster.STATE_CHANGE_REASON_BOOTSTRAP_FAILURE,
            "state_change_reason_message": "Bootstrapping steps failed.",
            "public_dns": None,
        },
    )
    spark_job.run()
    assert spark_job.latest_run.alerts.exists()
    assert len(mailoutbox) == 0
    tasks.send_run_alert_mails()
    assert len(mailoutbox) == 1
    message = mailoutbox[0]
    assert message.subject == (
        "%sRunning Spark job %s failed"
        % (settings.EMAIL_SUBJECT_PREFIX, spark_job.identifier)
    )

    assert message.from_email == settings.DEFAULT_FROM_EMAIL
    assert list(message.cc) == [settings.DEFAULT_FROM_EMAIL]
    assert list(message.to) == [spark_job.created_by.email] 
開發者ID:mozilla,項目名稱:telemetry-analysis-service,代碼行數:31,代碼來源:test_tasks.py

示例11: test_send_expired_mails

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def test_send_expired_mails(mailoutbox, mocker, now, spark_job):
    spark_job.expired_date = now
    spark_job.save()
    assert len(mailoutbox) == 0
    tasks.send_expired_mails()
    assert len(mailoutbox) == 1
    message = mailoutbox[0]
    assert message.subject == (
        "%sSpark job %s expired" % (settings.EMAIL_SUBJECT_PREFIX, spark_job.identifier)
    )
    assert message.from_email == settings.DEFAULT_FROM_EMAIL
    assert list(message.cc) == [settings.DEFAULT_FROM_EMAIL]
    assert list(message.to) == [spark_job.created_by.email]
    spark_job.refresh_from_db() 
開發者ID:mozilla,項目名稱:telemetry-analysis-service,代碼行數:16,代碼來源:test_tasks.py

示例12: get

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def get(self, request, *args, **kwargs):
        if request.user.is_authenticated:
            # Only anonymous (non-authenticated) users are expected to access this page.
            return HttpResponseRedirect(self.get_authenticated_redirect_url())
        request_id = request.session.pop('restore_request_id', None)
        if request_id is None or not isinstance(request_id[1], float):
            # When the restore request ID is missing or invalid, just show the login page.
            return HttpResponseRedirect(reverse_lazy('login'))
        if datetime.now() - datetime.fromtimestamp(request_id[1]) > timedelta(hours=1):
            # When the restore request ID is expired (older than 1 hour), redirect to the login page.
            # This is to prevent abuse, when the user leaves their browser or device open and
            # a different person attempts to (mis)use the restoration request functionality...
            messages.warning(self.request, _("Something misfunctioned. Please log in again and retry."))
            return HttpResponseRedirect(reverse_lazy('login'))
        # Otherwise, send mail to admins.
        send_mail(
            '{prefix}{subject}'.format(
                prefix=settings.EMAIL_SUBJECT_PREFIX,
                subject=gettext(
                    # xgettext:python-brace-format
                    "Note to admin: User requests to reactivate their account; ref: {}."
                ).format(request_id[0])),
            "--",
            None,
            ['{} <{}>'.format(nick, addr) for nick, addr in settings.ADMINS],
            fail_silently=False)
        context = self.get_context_data(**kwargs)
        return self.render_to_response(context) 
開發者ID:tejoesperanto,項目名稱:pasportaservo,代碼行數:30,代碼來源:views.py

示例13: _mail_admins_with_attachment

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def _mail_admins_with_attachment(
            subject,
            message,
            fail_silently=True,
            connection=None,
            html_message=None,
            attachments=None,
            extra_recipients: Optional[List[str]] = None,
    ):
        """
        Mimics mail_admins, but allows attaching files to the message
        """
        if not settings.ADMINS and not extra_recipients:
            return

        recipients = [a[1] for a in settings.ADMINS] + extra_recipients
        mail = EmailMultiAlternatives(
            "%s%s" % (settings.EMAIL_SUBJECT_PREFIX, subject),
            message, settings.SERVER_EMAIL, recipients,
            connection=connection
        )

        if html_message:
            mail.attach_alternative(html_message, "text/html")

        if attachments:
            for attachment_name, attachment_content, attachment_mime in attachments:
                mail.attach(attachment_name, attachment_content, attachment_mime)

        mail.send(fail_silently=fail_silently)


# Functions ##################################################################### 
開發者ID:open-craft,項目名稱:opencraft,代碼行數:35,代碼來源:utilities.py

示例14: test_register_user_by_email_confirmation

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def test_register_user_by_email_confirmation(self, send_mail):
        response, user = self.assert_user_registration('new-tester', follow=True)
        self.assertContains(
            response,
            _('Your account has been created, please check your mailbox for confirmation')
        )

        site = Site.objects.get(pk=settings.SITE_ID)
        confirm_url = 'http://%s%s' % (site.domain, reverse('tcms-confirm',
                                                            args=[self.fake_activate_key]))

        # Verify notification mail
        values = {
            'user': user.username,
            'site_domain': site.domain,
            'confirm_url': confirm_url,
        }
        expected_subject = settings.EMAIL_SUBJECT_PREFIX + \
            _('Your new %s account confirmation') % site.domain
        expected_body = _("""Welcome %(user)s,
thank you for signing up for an %(site_domain)s account!

To activate your account, click this link:
%(confirm_url)s""") % values + "\n"
        send_mail.assert_called_once_with(expected_subject, expected_body,
                                          settings.DEFAULT_FROM_EMAIL,
                                          ['new-tester@example.com'],
                                          fail_silently=False) 
開發者ID:kiwitcms,項目名稱:Kiwi,代碼行數:30,代碼來源:tests.py

示例15: mailto

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_SUBJECT_PREFIX [as 別名]
def mailto(template_name, subject, recipients=None,  # pylint: disable=invalid-name
           context=None, cc=None):

    # make a list with recipients and filter out duplicates
    if isinstance(recipients, list):
        recipients = list(set(recipients))
    else:
        recipients = [recipients]

    # extend with the CC list
    if cc:
        recipients.extend(cc)

    # if debugging then send to ADMINS as well
    if settings.DEBUG:
        for _, admin_email in settings.ADMINS:
            recipients.append(admin_email)

    # this is a workaround to allow passing body text directly
    if template_name:
        body = render_to_string(template_name, context)
    else:
        body = context

    sender = settings.DEFAULT_FROM_EMAIL
    email_thread = threading.Thread(
        target=send_mail,
        args=(settings.EMAIL_SUBJECT_PREFIX + subject, body, sender, recipients),
        kwargs={'fail_silently': False}
    )
    # This is to tell Python not to wait for the thread to return
    email_thread.setDaemon(True)
    email_thread.start() 
開發者ID:kiwitcms,項目名稱:Kiwi,代碼行數:35,代碼來源:mailto.py


注:本文中的django.conf.settings.EMAIL_SUBJECT_PREFIX屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。