当前位置: 首页>>代码示例>>Python>>正文


Python email.send_mail_template函数代码示例

本文整理汇总了Python中mezzanine.utils.email.send_mail_template函数的典型用法代码示例。如果您正苦于以下问题:Python send_mail_template函数的具体用法?Python send_mail_template怎么用?Python send_mail_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了send_mail_template函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_verification_mail_for_email_update

def send_verification_mail_for_email_update(request, user, new_email, verification_type):
    """
    Sends an email with a verification link to users when
    they update their email. The email is sent to the new email.
    The actual update of the email happens only after
    the verification link is clicked.
    The ``verification_type`` arg is both the name of the urlpattern for
    the verification link, as well as the names of the email templates
    to use.
    """
    verify_url = reverse(verification_type, kwargs={
        "uidb36": int_to_base36(user.id),
        "token": default_token_generator.make_token(user),
        "new_email": new_email
    }) + "?next=" + (next_url(request) or "/")
    context = {
        "request": request,
        "user": user,
        "new_email": new_email,
        "verify_url": verify_url,
    }
    subject_template_name = "email/%s_subject.txt" % verification_type
    subject = subject_template(subject_template_name, context)
    send_mail_template(subject, "email/%s" % verification_type,
                       settings.DEFAULT_FROM_EMAIL, new_email,
                       context=context)
开发者ID:hydroshare,项目名称:hydroshare,代码行数:26,代码来源:views.py

示例2: send_order_email

def send_order_email(request, order):
    """
    Send order receipt email on successful order.
    """
    settings.use_editable()

    address = request.session['address']

    store = request.session['stores']
    store_name = store[0].name
    store_address = store[0].address
    store_contact = store[0].contact_number

    order_context = {"order": order, "request": request,
                     "order_items": order.items.all(), "address": address,
                     "store_name": store_name, "store_address": store_address,
                     "store_contact": store_contact}
    order_context.update(order.details_as_dict())
    try:
        get_template("shop/email/order_receipt.html")
    except TemplateDoesNotExist:
        receipt_template = "email/order_receipt"
    else:
        receipt_template = "shop/email/order_receipt"
        from warnings import warn
        warn("Shop email receipt templates have moved from "
             "templates/shop/email/ to templates/email/")
    send_mail_template(settings.SHOP_ORDER_EMAIL_SUBJECT,
        receipt_template, settings.SHOP_ORDER_FROM_EMAIL,
        order.billing_detail_email, context=order_context,
        fail_silently=settings.DEBUG)
开发者ID:obsjames,项目名称:md-production-public,代码行数:31,代码来源:checkout.py

示例3: modularpage_processor

def modularpage_processor(request, page):
    formblock_ct = ContentType.objects.get(app_label='clubhouse_forms',\
            model='formblock')

    # TODO: Fix this to find form objects in any of the BlockContexts registered here
    formblocks = page.modularpage.content.filter(block_type=formblock_ct)
    from clubhouse.forms import Initialised

    for formblock in formblocks:
        registry_key = 'form:%s' % formblock.block_object.pk
        form_model = formblock.block_object.form
        form = FormForForm(formblock.block_object.form, RequestContext(request),
                           None, None)

        post_data = request.POST or {}
        if form.submit_key in post_data:
            form = FormForForm(formblock.block_object.form,
                    RequestContext(request), request.POST, request.FILES or None)

        if form.is_valid():
            url = page.get_absolute_url()
            if is_spam(request, form, url):
                return redirect(url)
            attachments = []
            for f in form.files.values():
                f.seek(0)
                attachments.append((f.name, f.read()))
            entry = form.save()
            subject = form_model.email_subject
            if not subject:
                subject = "%s - %s" % (form_model.title, entry.entry_time)
            fields = [(v.label, format_value(form.cleaned_data[k]))
                      for (k, v) in form.fields.items()]
            context = {
                "fields": fields,
                "message": form_model.email_message,
                "request": request,
            }
            email_from = form_model.email_from or settings.DEFAULT_FROM_EMAIL
            email_to = form.email_to()
            if email_to and form_model.send_email:
                send_mail_template(subject, "email/form_response", email_from,
                                   email_to, context)
            headers = None
            if email_to:
                # Add the email entered as a Reply-To header
                headers = {'Reply-To': email_to}
            email_copies = split_addresses(form_model.email_copies)
            if email_copies:
                send_mail_template(subject, "email/form_response_copies",
                                   email_from, email_copies, context,
                                   attachments=attachments, headers=headers)
            form_valid.send(sender=request, form=form, entry=entry)
            form.is_submitted = True
        else:
            form_invalid.send(sender=request, form=form)

        Initialised.register(registry_key, form)

    return {}
开发者ID:chazmead,项目名称:django-clubhouse,代码行数:60,代码来源:page_processors.py

示例4: reservation_send

def reservation_send(request):
    if not request.is_ajax():
        raise Http404()

    if request.method != 'POST':
        raise Http404()

    f = settings.RESERV_EMAIL_FROM
    t = settings.RESERV_EMAIL_TO
    if f and t:
        C = {
            'message': "Reservation request raised",
            'fields': []
        }

        for k, v in request.POST.iteritems():
            if k != 'csrfmiddlewaretoken':
                C['fields'].append((k,v,))

        send_mail_template(
            addr_from=f,
            addr_to=[t, ],
            template='email/form_response',
            subject="WEB RESERVATION REQUEST",
            context=C,
        )

    return HttpResponse("test")
开发者ID:skada,项目名称:mezzanine-tools,代码行数:28,代码来源:views.py

示例5: save

    def save(self, request):
        """
        Saves a new comment and sends any notification emails.
        """
        comment = self.get_comment_object()
        obj = comment.content_object
        if request.user.is_authenticated():
            comment.user = request.user
            comment.user_name = best_name(comment.user)

        comment.by_author = request.user == getattr(obj, "user", None)
        comment.ip_address = ip_for_request(request)
        comment.replied_to_id = self.data.get("replied_to")
        comment.save()
        comment_was_posted.send(sender=comment.__class__, comment=comment,
                                request=request)
        notify_emails = split_addresses(settings.COMMENTS_NOTIFICATION_EMAILS)
        notify_emails.append(obj.user.email)
        reply_to_comment = comment.replied_to
        if reply_to_comment is not None:
            notify_emails.append(reply_to_comment.user.email)
        if notify_emails:
            subject = "[HydroShare Support] New comment by {c_name} for: {res_obj}".format(
                c_name=comment.user_name, res_obj=str(obj))
            context = {
                "comment": comment,
                "comment_url": add_cache_bypass(comment.get_absolute_url()),
                "request": request,
                "obj": obj,
            }
            send_mail_template(subject, "email/comment_notification",
                               settings.DEFAULT_FROM_EMAIL, notify_emails,
                               context)

        return comment
开发者ID:hydroshare,项目名称:hydroshare,代码行数:35,代码来源:forms.py

示例6: save

 def save(self, request):
     """
     Saves a new comment and sends any notification emails.
     """
     comment = self.get_comment_object()
     obj = comment.content_object
     if request.user.is_authenticated():
         comment.user = request.user
     comment.by_author = request.user == getattr(obj, "user", None)
     comment.ip_address = ip_for_request(request)
     comment.replied_to_id = self.data.get("replied_to")
     comment.save()
     comment_was_posted.send(sender=comment.__class__, comment=comment,
                             request=request)
     notify_emails = split_addresses(settings.COMMENTS_NOTIFICATION_EMAILS)
     if notify_emails:
         subject = _("New comment for: ") + str(obj)
         context = {
             "comment": comment,
             "comment_url": add_cache_bypass(comment.get_absolute_url()),
             "request": request,
             "obj": obj,
         }
         send_mail_template(subject, "email/comment_notification",
                            settings.DEFAULT_FROM_EMAIL, notify_emails,
                            context)
     return comment
开发者ID:EthanBlackburn,项目名称:mezzanine,代码行数:27,代码来源:forms.py

示例7: post

    def post(self, request, *args, **kwargs):
        order = Order.objects.get(pk=kwargs['pk'])

        if order.status == 1:
            order.status = 2 # set to payed
            order.save()

            order_context = {"order": order, "request": request,
                             "order_items": order.items.all()}
            order_context.update(order.details_as_dict())

            # send email with order to producer
            send_mail_template("Bestellung #%i" % order.id,
                           "email/producer_notification",
                           settings.SHOP_ORDER_FROM_EMAIL,
                           settings.SHOP_PRODUCER_EMAIL,
                           context=order_context,
                           addr_bcc=settings.SHOP_ORDER_EMAIL_BCC or None)

            # send email with payment received notification to customer
            send_mail_template("Zahlung zu Bestellung #%i erhalten" % order.id,
                           "email/customer_notification",
                           settings.SHOP_ORDER_FROM_EMAIL,
                           order.billing_detail_email,
                           context=order_context)

        return redirect('order_detail', pk=order.pk)
开发者ID:wittwerch,项目名称:1107,代码行数:27,代码来源:views.py

示例8: send_email_to_requester

    def send_email_to_requester(self, request):
        template = "openhelpdesk/email/report/info_to_request"
        operator = request.user
        operator_name = operator.username
        if operator.last_name and operator.first_name:
            operator_name = '{} {}'.format(operator.first_name,
                                           operator.last_name)
        context = {'report_name': self._meta.verbose_name.lower(),
                   'operator': operator,
                   'operator_name': operator_name,
                   'ticket_id': self.ticket_id,
                   'email_background_color': (
                       OrganizationSetting.email_objects.get_color(
                           self.ticket.requester.email))}

        try:
            site_conf = SiteConfiguration.objects.get(site=self.ticket.site)
            addr_from = site_conf.email_addr_from
        except (SiteConfiguration.DoesNotExist, Ticket.DoesNotExist):
            addr_from = SiteConfiguration.get_no_site_email_addr_from()

        subject = subject_template("{}_subject.html".format(template), context)
        addr_to = [self.ticket.requester.email]
        change_ticket_url = '{}#tab_messages'.format(
            reverse(admin_urlname(self.ticket._meta, 'change'),
                    args=(self.ticket_id,)))
        context.update({'report': self, 'request': request,
                        'change_ticket_url': change_ticket_url})
        send_mail_template(subject, template, addr_from, addr_to,
                           context=context, attachments=None)
开发者ID:simodalla,项目名称:open-helpdesk,代码行数:30,代码来源:models.py

示例9: send_order_email

def send_order_email(request, order):
    """
    Send order receipt email on successful order.
    """
    settings.use_editable()
    order_context = {"order": order, "request": request,
                     "order_items": order.items.all()}
    if order.has_reservables:
        order_context["has_reservables"] = True
    else:
        order_context["has_reservables"] = False
    order_context["hide_shipping"] = settings.SHOP_ALWAYS_SAME_BILLING_SHIPPING
    order_context.update(order.details_as_dict())
    try:
        get_template("shop/email/order_receipt.html")
    except TemplateDoesNotExist:
        receipt_template = "email/order_receipt"
    else:
        receipt_template = "shop/email/order_receipt"
        from warnings import warn
        warn("Shop email receipt templates have moved from "
             "templates/shop/email/ to templates/email/")
    send_mail_template(settings.SHOP_ORDER_EMAIL_SUBJECT,
                       receipt_template, settings.SHOP_ORDER_FROM_EMAIL,
                       order.billing_detail_email, context=order_context,
                       addr_bcc=settings.SHOP_ORDER_EMAIL_BCC or None)
开发者ID:jaywink,项目名称:cartridge-reservable,代码行数:26,代码来源:checkout.py

示例10: send_email_to_operators_on_adding

    def send_email_to_operators_on_adding(self, request):
        template = "openhelpdesk/email/ticket/ticket_operators_creation"
        requester_name = _('no personal info assigned')
        if self.requester.last_name and self.requester.first_name:
            requester_name = '{} {}'.format(self.requester.first_name,
                                            self.requester.last_name)
        subject = subject_template(
            "{}_subject.html".format(template),
            {'ticket_name': self._meta.verbose_name.lower(),
             'username': self.requester.email or self.requester.username})
        try:
            site_conf = SiteConfiguration.objects.get(site=self.site)
            addr_from = site_conf.email_addr_from
            addr_to = site_conf.email_addrs_to
        except SiteConfiguration.DoesNotExist:
            addr_from = SiteConfiguration.get_no_site_email_addr_from()
            addr_to = SiteConfiguration.get_no_site_email_addrs_to()
        change_url = reverse(admin_urlname(self._meta, 'change'),
                             args=(self.pk,))

        email_background_color = (
            OrganizationSetting.email_objects.get_color(
                self.requester.email))
        context = {'ticket_name': self._meta.verbose_name, 'ticket': self,
                   'request': request, 'change_url': change_url,
                   'requester_username': self.requester.username,
                   'requester_email': self.requester.email or _(
                       'no email assigned'),
                   'requester_name': requester_name,
                   'email_background_color': email_background_color}
        send_mail_template(subject, template, addr_from, addr_to,
                           context=context, attachments=None)
开发者ID:simodalla,项目名称:open-helpdesk,代码行数:32,代码来源:models.py

示例11: send_store_order_email

def send_store_order_email(request, order):
    """
    Send order email to store on successful order.
    """
    settings.use_editable()

    address = request.session['address']
    store = request.session['stores']
    store_name = store[0].name
    store_email = [store[0].email]

    store_name_no_spaces = store_name.replace(" ", "")

    order_context = {"order": order, "request": request,
                     "order_items": order.items.all(), "address": address,
                     "store_name": store_name, "store_name_no_spaces": store_name_no_spaces}
    order_context.update(order.details_as_dict())
    try:
        get_template("shop/email/store_order.html")
    except TemplateDoesNotExist:
        receipt_template = "email/store_order"
    else:
        receipt_template = "shop/email/store_order"
        from warnings import warn
        warn("Shop email receipt templates have moved from "
             "templates/shop/email/ to templates/email/")
    send_mail_template(settings.SHOP_STORE_ORDER_EMAIL_SUBJECT,
        receipt_template, settings.SHOP_ORDER_FROM_EMAIL,
        store_email, context=order_context,
        fail_silently=settings.DEBUG)
开发者ID:obsjames,项目名称:md-production-public,代码行数:30,代码来源:checkout.py

示例12: send_order_email

def send_order_email(request, order):
    """
    Send order receipt email on successful order.
    """
    settings.use_editable()
    order_context = {"order": order, "request": request,
                     "order_items": order.items.all()}
    order_context.update(order.details_as_dict())
    from mezzanine.utils.email import send_mail_template
    send_mail_template(_("Order Receipt"), "email/order_receipt",
        settings.SHOP_ORDER_FROM_EMAIL, order.billing_detail_email,
        context=order_context, fail_silently=settings.DEBUG)
开发者ID:zs425,项目名称:Manai-python-,代码行数:12,代码来源:checkout.py

示例13: order_handler

def order_handler(request, order_form, order):
  """
  Default order handler - called when the order is complete and
  contains its final data. Implement your own and specify the path
  to import it from via the setting ``SHOP_HANDLER_ORDER``.
  """
  settings.use_editable()
  items = order.items.all()
  
  customer_type = 'Retail'
  user_id = order.user_id
  
  if user_id:
    try:
      user = User.objects.get(id=user_id)
    except:
      pass
    else:
      if user.has_perm('custom.wholesale_customer'):
        customer_type = 'Wholesale'

  company_name = ''
  website = ''
  fullurl = ''
  if customer_type == 'Wholesale':
    try:
      company_name = user.get_profile().company_name
      website = user.get_profile().website
    except:
      pass
    else:
      if website:
        if "http://" not in website:
          fullurl = "http://" + website
        else:
          fullurl = website

  order_context = {
    "order": order,
    "request": request,
    "order_items": items,
    "customer_type": customer_type,
    "company_name": company_name,
    "website": website,
  }
  order_context.update(order.details_as_dict())
  from mezzanine.utils.email import send_mail_template
  send_mail_template(_(customer_type + " Order Completed on manai.co.uk"), "email/order_alert",
      settings.SERVER_EMAIL, settings.DEFAULT_FROM_EMAIL,
      context=order_context, fail_silently=settings.DEBUG)
开发者ID:zs425,项目名称:Manai-python-,代码行数:50,代码来源:checkout.py

示例14: send_registration_confirmation_email

def send_registration_confirmation_email(request):
  """
  Send order receipt email on successful order.
  """
  settings.use_editable()
  context = {"user": request.user, "site_url": settings.SITE_URL}
  template = "email/registration_confirmation"

  send_mail_template( "Thank you for registering with Manai",
                      template,
                      settings.SHOP_ORDER_FROM_EMAIL,
                      request.user.email,
                      context=context,
                      fail_silently=settings.DEBUG)
开发者ID:zs425,项目名称:Manai-python-,代码行数:14,代码来源:views.py

示例15: send_invite_code_mail

def send_invite_code_mail(code, site_url, login_url):
    context = {
        'code': code,
        'site_name': settings.SITE_TITLE,
        'site_url': site_url,
        'login_url': login_url,
    }
    send_mail_template(
        "Your Invitation to %s" % settings.SITE_TITLE,
        "invites/send_invite_email",
        settings.DEFAULT_FROM_EMAIL,
        code.registered_to,
        context=context,
        fail_silently=False,
    )
开发者ID:averagehuman,项目名称:mezzanine-invites,代码行数:15,代码来源:utils.py


注:本文中的mezzanine.utils.email.send_mail_template函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。