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


Python settings.SERVER_EMAIL屬性代碼示例

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


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

示例1: post

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [as 別名]
def post(self, request, *args, **kwargs):
        autonomous_system = get_object_or_404(AutonomousSystem, asn=kwargs["asn"])

        if not autonomous_system.can_receive_email:
            redirect(autonomous_system.get_absolute_url())

        form = AutonomousSystemEmailForm(request.POST)
        form.fields[
            "recipient"
        ].choices = autonomous_system.get_contact_email_addresses()

        if form.is_valid():
            sent = send_mail(
                form.cleaned_data["subject"],
                form.cleaned_data["body"],
                settings.SERVER_EMAIL,
                [form.cleaned_data["recipient"]],
            )
            if sent == 1:
                messages.success(request, "Email sent.")
            else:
                messages.error(request, "Unable to send the email.")

        return redirect(autonomous_system.get_absolute_url()) 
開發者ID:respawner,項目名稱:peering-manager,代碼行數:26,代碼來源:views.py

示例2: submit

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [as 別名]
def submit(request):
    send_mail(
        "User feedback from Dirigible",
        dedent("""
            Username: %s
            Email address: %s
            Page: %s

            Message:
            %s
        """) % (
            request.POST["username"], request.POST["email_address"],
            request.META['HTTP_REFERER'], request.POST["message"]
        ),
        settings.SERVER_EMAIL,
        [settings.FEEDBACK_EMAIL]
    )
    return HttpResponse("OK") 
開發者ID:pythonanywhere,項目名稱:dirigible-spreadsheet,代碼行數:20,代碼來源:views.py

示例3: create_profile

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [as 別名]
def create_profile(sender, **kwargs):
    user = kwargs["instance"]
    if kwargs["created"]:
        default_plan = Plan.objects.get(pk=Plan.DEFAULT_PK)
        up = Profile(user=user, plan=default_plan)
        up.save()
        try:
            for tg in TalkGroupAccess.objects.filter(default_group=True):
                up.talkgroup_access.add(tg)
        except OperationalError:
            pass
        try:
            new_user_email = SiteOption.objects.get(name='SEND_ADMIN_EMAIL_ON_NEW_USER')
            if new_user_email.value_boolean_or_string() == True:
                send_mail(
                      'New {} User {}'.format(settings.SITE_TITLE, user.username),
                      'New User {} {} Username {} Email {} just registered'.format(user.first_name, user.last_name, user.username, user.email),
                      settings.SERVER_EMAIL,
                      [ mail for name, mail in settings.ADMINS],
                      fail_silently=False,
                     )
        except (SiteOption.DoesNotExist, OperationalError):
            pass 
開發者ID:ScanOC,項目名稱:trunk-player,代碼行數:25,代碼來源:models.py

示例4: mail_comment

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [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

示例5: mail_file

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [as 別名]
def mail_file(request, file_id):
    from yats.models import tickets_files
    io = tickets_files.objects.get(pk=file_id)
    ticket_id = io.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:
        body = '%s\n%s: %s\n%s: %s\n%s: %s\n\n%s' % (_('new file added'), _('file name'), io.name, _('file size'), io.size, _('content type'), io.content_type, get_ticket_url(request, ticket_id))

        try:
            send_mail('%s#%s: %s - %s' % (settings.EMAIL_SUBJECT_PREFIX, tic.id, _('new file'), tic.caption), body, 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:
        body = '%s\n%s: %s\n%s: %s\n%s: %s\n\n%s' % (_('new file added'), _('file name'), io.name, _('file size'), io.size, _('content type'), io.content_type, get_ticket_url(request, ticket_id, for_customer=True))

        try:
            send_mail('%s#%s: %s - %s' % (settings.EMAIL_SUBJECT_PREFIX, tic.id, _('new file'), tic.caption), body, settings.SERVER_EMAIL, int_rcpt, False)
        except Exception:
            messages.add_message(request, messages.ERROR, _('mail not send: %s') % sys.exc_info()[1]) 
開發者ID:mediafactory,項目名稱:yats,代碼行數:25,代碼來源:shortcuts.py

示例6: mail_admins

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [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

示例7: mail_managers

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [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

示例8: _mail_admins_with_attachment

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [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

示例9: test_provision_failed_email

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [as 別名]
def test_provision_failed_email(self, mock_consul):
        """
        Tests that provision_failed sends email when called from normal program flow
        """
        additional_monitoring_emails = ['additionalmonitoring@localhost']
        failure_emails = ['provisionfailed@localhost']

        appserver = make_test_appserver()
        appserver.instance.additional_monitoring_emails = additional_monitoring_emails
        appserver.instance.provisioning_failure_notification_emails = failure_emails
        reason = "something went wrong"
        log_lines = ["log line1", "log_line2"]

        appserver.provision_failed_email(reason, log_lines)

        expected_subject = OpenEdXAppServer.EmailSubject.PROVISION_FAILED.format(
            name=appserver.name, instance_name=appserver.instance.name,
        )
        # failure_emails isn't included here because they get a different type of email (an urgent one)
        expected_recipients = [admin_tuple[1] for admin_tuple in settings.ADMINS]

        self.assertEqual(len(django_mail.outbox), 1)
        mail = django_mail.outbox[0]

        self.assertIn(expected_subject, mail.subject)
        self.assertIn(appserver.name, mail.body)
        self.assertIn(appserver.instance.name, mail.body)
        self.assertIn(reason, mail.body)
        self.assertEqual(mail.from_email, settings.SERVER_EMAIL)
        self.assertEqual(mail.to, expected_recipients)

        self.assertEqual(len(mail.attachments), 1)
        self.assertEqual(mail.attachments[0], ("provision.log", "\n".join(log_lines), "text/plain")) 
開發者ID:open-craft,項目名稱:opencraft,代碼行數:35,代碼來源:test_openedx_appserver.py

示例10: test_provision_failed_exception_email

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [as 別名]
def test_provision_failed_exception_email(self, mock_consul):
        """
        Tests that provision_failed sends email when called from exception handler
        """
        appserver = make_test_appserver()
        reason = "something went wrong"
        log_lines = ["log line1", "log_line2"]

        exception_message = "Something Bad happened Unexpectedly"
        exception = Exception(exception_message)
        try:
            raise exception
        except Exception:  # pylint: disable=broad-except
            appserver.provision_failed_email(reason, log_lines)

        expected_subject = OpenEdXAppServer.EmailSubject.PROVISION_FAILED.format(
            name=appserver.name, instance_name=appserver.instance.name,
        )
        expected_recipients = [admin_tuple[1] for admin_tuple in settings.ADMINS]

        self.assertEqual(len(django_mail.outbox), 1)
        mail = django_mail.outbox[0]

        self.assertIn(expected_subject, mail.subject)
        self.assertIn(appserver.name, mail.body)
        self.assertIn(appserver.instance.name, mail.body)
        self.assertIn(reason, mail.body)
        self.assertEqual(mail.from_email, settings.SERVER_EMAIL)
        self.assertEqual(mail.to, expected_recipients)

        self.assertEqual(len(mail.attachments), 2)
        self.assertEqual(mail.attachments[0], ("provision.log", "\n".join(log_lines), "text/plain"))
        name, content, mime_type = mail.attachments[1]
        self.assertEqual(name, "debug.html")
        self.assertIn(exception_message, content)
        self.assertEqual(mime_type, "text/html") 
開發者ID:open-craft,項目名稱:opencraft,代碼行數:38,代碼來源:test_openedx_appserver.py

示例11: test_submit_with_message_and_email_address_and_username_sends_admin_email_with_all_three

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [as 別名]
def test_submit_with_message_and_email_address_and_username_sends_admin_email_with_all_three(self, mock_send_mail):
        request = HttpRequest()
        request.POST["message"] = "a test message"
        request.POST["email_address"] = "a test email address"
        request.POST["username"] = "a test username"
        request.META['HTTP_REFERER'] = 'a test page'

        response = submit(request)

        self.assertTrue(isinstance(response, HttpResponse))
        self.assertEquals(response.content, "OK")

        self.assertCalledOnce(
            mock_send_mail,
            "User feedback from Dirigible",
            dedent("""
                Username: a test username
                Email address: a test email address
                Page: a test page

                Message:
                a test message
            """),
            settings.SERVER_EMAIL,
            [settings.FEEDBACK_EMAIL]
        ) 
開發者ID:pythonanywhere,項目名稱:dirigible-spreadsheet,代碼行數:28,代碼來源:test_views.py

示例12: form_valid

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [as 別名]
def form_valid(self, form):
        try:
            update_unit_email = SiteOption.objects.get(name='SEND_ADMIN_EMAIL_ON_UNIT_NAME')
            if update_unit_email.value_boolean_or_string() == True:
                Unit = form.save()
                send_mail(
                  'Unit ID Change',
                  'User {} updated unit ID {} Now {}'.format(self.request.user, Unit.dec_id, Unit.description),
                  settings.SERVER_EMAIL,
                  [ mail for name, mail in settings.ADMINS],
                  fail_silently=False,
                )
        except SiteOption.DoesNotExist:
            pass
        return super().form_valid(form) 
開發者ID:ScanOC,項目名稱:trunk-player,代碼行數:17,代碼來源:views.py

示例13: forward_to_admins

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [as 別名]
def forward_to_admins(message, local=None, domain=None):
    if message.is_bounce():
        # log and swallow the message
        log.warning("Detected message bounce %s, subject: %s", message, message["Subject"])
        return

    try:
        Relay().deliver(message, To=[m[1] for m in settings.ADMINS], From=settings.SERVER_EMAIL)
    except Exception as excp:
        log.exception("Error while forwarding admin message %s: %s", id(message), excp)
        raise SMTPError(450, "Error while forwarding admin message %s" % id(message)) 
開發者ID:Inboxen,項目名稱:Inboxen,代碼行數:13,代碼來源:server.py

示例14: send_email

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [as 別名]
def send_email(self, filename):
        # send email
        email = EmailMultiAlternatives(
            subject='[Olympia tradingdb backup]',
            body='tradingdb backup attached.',
            from_email=settings.SERVER_EMAIL,
            to=[a[1] for a in settings.ADMINS]
        )
        email.attach_file(filename)
        email.send() 
開發者ID:gnosis,項目名稱:pm-trading-db,代碼行數:12,代碼來源:db_dump.py

示例15: mail_ticket

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SERVER_EMAIL [as 別名]
def mail_ticket(request, ticket_id, form, **kwargs):
    int_rcpt, pub_rcpt = list(get_mail_recipient_list(request, ticket_id))
    tic = get_ticket_model().objects.get(pk=ticket_id)
    if not tic.assigned:
        if 'rcpt' in kwargs and kwargs['rcpt']:
            rcpts = kwargs['rcpt'].split(',')
            for rcpt in rcpts:
                if rcpt not in int_rcpt:
                    int_rcpt.append(rcpt)

    new, old = field_changes(form)

    if len(int_rcpt) > 0:
        try:
            new['author'] = tic.c_user
            send_mail('%s#%s - %s' % (settings.EMAIL_SUBJECT_PREFIX, tic.id, tic.caption), '%s\n\n%s' % (format_chanes(new, True), get_ticket_url(request, ticket_id)), settings.SERVER_EMAIL, int_rcpt, False)
        except:
            if not kwargs.get('is_api', False):
                messages.add_message(request, messages.ERROR, _('mail not send: %s') % sys.exc_info()[1])

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


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