django.conf.settings.DEFAULT_FROM_EMAIL

Here are the examples of the python api django.conf.settings.DEFAULT_FROM_EMAIL taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

Example 1

Project: django-allauth
Source File: adapter.py
View license
    def get_from_email(self):
        """
        This is a hook that can be overridden to programatically
        set the 'from' email address for sending emails
        """
        return settings.DEFAULT_FROM_EMAIL

Example 2

Project: django-waitinglist
Source File: make_contact.py
View license
    def make_contact(self):
        cards = self.api.cards(self.api.to_contact_list_id)
        for card in cards:
            try:
                entry = WaitingListEntry.objects.filter(initial_contact_sent=False)\
                    .get(trello_card_id=card["id"])
                subject = render_to_string(
                    "waitinglist/email/initial_contact_subject.txt", {"entry": entry})
                message = render_to_string(
                    "waitinglist/email/initial_contact.txt", {"entry": entry})
                send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [entry.email])
                self.api.move_card(card["id"], self.api.contacted_list_id)
                entry.initial_contact_sent = True
                entry.save()
                print "Sent to {0} ({1}) [Card #{2}]".format(
                    card["name"], card["shortUrl"], card["idShort"])
            except WaitingListEntry.DoesNotExist:
                print "{0} ({1}) has already been sent [Card #{2}]".format(
                    card["name"], card["shortUrl"], card["idShort"])

Example 3

Project: GAE-Bulk-Mailer
Source File: base.py
View license
  def __init__ (self, subject, reply_to, text_tpl, html_tpl, list_id, campaign_id, from_name, salt, analytics):
    self.subject = subject
    self.reply_to = reply_to
    self.text_tpl = text_tpl
    self.html_tpl = html_tpl
    self.list_id = list_id
    self.campaign_id = campaign_id
    self.salt = salt
    self.analytics = analytics
    
    self.text_urls = {}
    self.html_urls = {}
    
    self.frm = settings.DEFAULT_FROM_EMAIL
    if from_name:
      self.frm = '%s <%s>' % (from_name, settings.DEFAULT_FROM_EMAIL)
      
    self.url_regex = re.compile(r"""(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>\[\]]+|\(([^\s()<>\[\]]+|(\([^\s()<>\[\]]+\)))*\))+(?:\(([^\s()<>\[\]]+|(\([^\s()<>\[\]]+\)))*\)|[^\s`!(){};:'".,<>?\[\]]))""")

Example 4

Project: PyClassLessons
Source File: test_views.py
View license
    def test_email_found(self):
        "Email is sent if a valid email address is provided for password reset"
        response = self.client.post('/password_reset/', {'email': '[email protected]'})
        self.assertEqual(response.status_code, 302)
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue("http://" in mail.outbox[0].body)
        self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)
        # optional multipart text/html email has been added.  Make sure original,
        # default functionality is 100% the same
        self.assertFalse(mail.outbox[0].message().is_multipart())

Example 5

Project: Misago
Source File: testemailsetup.py
View license
    def send_message(self, email):
        mail.send_mail(
            'Test Message',
            ("This message was sent to test if your "
             "site e-mail is configured correctly."),
            settings.DEFAULT_FROM_EMAIL,
            [email],
            fail_silently=False)
        self.stdout.write("Test message was sent to %s" % email)

Example 6

Project: django-shop
Source File: test_customer.py
View license
    def test_save(self):
        data = {'email': '[email protected]'}
        request = APIRequestFactory().post('/', data)
        serializer = PasswordResetSerializer(data=data, context={
            'request': request,
        })
        self.assertTrue(serializer.is_valid())
        serializer.reset_form = mock.Mock()
        serializer.save()
        serializer.reset_form.save.assert_called_with(
            use_https=False,
            from_email=settings.DEFAULT_FROM_EMAIL,
            request=request,
            subject_template_name=u'shop/email/reset-password-subject.txt',
            email_template_name='shop/email/reset-password-body.txt',
        )

Example 7

Project: classic.rhizome.org
Source File: models.py
View license
@receiver(post_save, sender=GrantProposal, dispatch_uid='commissions.send_confirmation')
def send_confirmation(sender, instance, created, **kwargs):
    if created:
        if instance.data_dict.get('email'):
            instance.grant.confirmation_email.send(
                settings.DEFAULT_FROM_EMAIL,
                [instance.data_dict.get('email')],
                extra_context={})

Example 8

Project: django-notifier
Source File: backends.py
View license
    def send(self, user, context=None):
        super(EmailBackend, self).send(user, context)

        subject = render_to_string(self.template_subject, self.context)
        subject = ''.join(subject.splitlines())
        message = render_to_string(self.template_message, self.context)

        try:
            send_mail(subject, message, settings.DEFAULT_FROM_EMAIL,
                [user.email])
        except SMTPException:
            return False
        else:
            return True

Example 9

Project: coursys
Source File: models.py
View license
    def email_from(self):
        """
        Determine who the email should appear to come from: perfer to use course contact email if exists.
        """
        if self.course and self.course.taemail():
            if self.author:
                return "%s <%s> (per %s)" % (self.course.name(), self.course.taemail(), self.author.name())
            else:
                return "%s <%s>" % (self.course.name(), self.course.taemail())
        elif self.author:
            return self.author.full_email()
        else:
            return settings.DEFAULT_FROM_EMAIL

Example 10

Project: coursys
Source File: models.py
View license
    def email_started(self, request):
        full_url = request.build_absolute_uri(self.get_submission_url())
        context = {'initiator': self.filler.name(), 'sheeturl': full_url, 'sheetsub': self}
        subject = u'%s submission incomplete' % (self.sheet.form.title)
        self._send_email(request, 'nonsfu_sheet_started', subject,
                         settings.DEFAULT_FROM_EMAIL, [self.filler.full_email()], context)

        FormLogEntry.create(sheet_submission=self, category='MAIL',
                        description=u'Notified %s that they saved an incomplete sheet.' % (self.filler.full_email(),))

Example 11

Project: baruwa
Source File: views.py
View license
@login_required
@onlysuperusers
def test_host(request, host_id):
    'Tests SMTP delivery to mail host'

    host = get_object_or_404(MailHost, id=host_id)

    test_address = "[email protected]%s" % host.useraddress.address
    from_addr = settings.DEFAULT_FROM_EMAIL
    server = TestSMTPServer()
    task = server.delay(host.address, host.port,
    from_addr, test_address, host.useraddress.id, 5)
    return HttpResponseRedirect(reverse('conn-status', args=[task.task_id]))

Example 12

Project: django-spreedly
Source File: models.py
View license
    def send_activation_email(self):
        if not self.sent_at: #don't spam user with invitations
            send_mail(
                spreedly_settings.SPREEDLY_GIFT_EMAIL_SUBJECT,
                render_to_string(spreedly_settings.SPREEDLY_GIFT_EMAIL, {
                    'message': self.message,
                    'plan_name': self.plan_name,
                    'giver': '%s (%s)' % (self.from_user, self.from_user.email),
                    'site': spreedly_settings.SPREEDLY_SITE_URL,
                    'register_url': self.get_activation_url()
                }),
                settings.DEFAULT_FROM_EMAIL,
                [self.to_user.email,]
            )
            self.sent_at = datetime.today()
            self.save()

Example 13

Project: oioioi
Source File: controllers.py
View license
    def send_email(self, subject, body, recipients, headers=None):
        """Send an email about something related to this contest
            (e.g. a submission confirmation).
            ``From:`` is set to DEFAULT_FROM_EMAIL,
            ``Reply-To:`` is taken from the ``Contact email`` contest setting
                and defaults to the value of ``From:``.
        """
        replyto = settings.DEFAULT_FROM_EMAIL
        if self.contest.contact_email:
            replyto = self.contest.contact_email

        final_headers = {'Reply-To': replyto}
        if headers:
            final_headers.update(headers)
        email = EmailMessage(subject, body, settings.DEFAULT_FROM_EMAIL,
                recipients, headers=final_headers)
        email.send()

Example 14

Project: splunk-webframework
Source File: views.py
View license
    def test_email_found(self):
        "Email is sent if a valid email address is provided for password reset"
        response = self.client.post('/password_reset/', {'email': '[email protected]'})
        self.assertEqual(response.status_code, 302)
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue("http://" in mail.outbox[0].body)
        self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)

Example 15

Project: froide
Source File: send_mass_mail.py
View license
    def send_mail(self, subject, content):
        users = User.objects.filter(is_active=True)
        users = users.exclude(email='')

        for user in users.iterator():
            send_mail(subject, content, settings.DEFAULT_FROM_EMAIL,
                [user.email], fail_silently=False)
            yield user.pk

Example 16

Project: django-userprofiles
Source File: forms.py
View license
    def save(self, user):
        verification = EmailVerification.objects.create(user=user,
            old_email=user.email, new_email=self.cleaned_data['new_email'])

        context = {
            'user': user,
            'verification': verification,
            'site': Site.objects.get_current(),
        }

        subject = ''.join(render_to_string(
            'userprofiles/mails/emailverification_subject.html', context).splitlines())
        body = render_to_string('userprofiles/mails/emailverification.html', context)

        send_mail(subject, body, settings.DEFAULT_FROM_EMAIL,
            [self.cleaned_data['new_email']])

        return verification

Example 17

Project: web
Source File: views.py
View license
    def form_valid(self, form):
        subject = '[studentenportal.ch] Neue Dokument-Meldung'
        sender = settings.DEFAULT_FROM_EMAIL
        receivers = [a[1] for a in settings.ADMINS]
        msg_tpl = 'Es gibt eine neue Meldung zum Dokument "{document.name}" ' + \
                  '(PK {document.pk}):\n\n' + \
                  'Melder: {name} ({email})\n' + \
                  'Grund: {reason}\n' + \
                  'Nachricht: {comment}\n\n' + \
                  'Link auf Dokument: https://studentenportal.ch{url}'
        admin_url = reverse('admin:documents_document_change', args=(self.object.pk,))
        msg = msg_tpl.format(document=self.object, url=admin_url, **form.cleaned_data)
        send_mail(subject, msg, sender, receivers, fail_silently=False)

        return super(DocumentReport, self).form_valid(form)

Example 18

Project: django-signup
Source File: views.py
View license
def _send_activation_email(profile):
    # Render activation email
    message = render_to_string('signup/activation_email.txt',
                                {'signup_key': profile.signup_key})
    subject = render_to_string('signup/activation_email_subject.txt')
    # Send activation email
    send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [profile.email,],
                fail_silently=True)

Example 19

Project: gallery
Source File: tests.py
View license
    def test_valid(self):
        """
        Test that the valid email addresses will get an email.
        """
        form_data = {'email': self.user.email}
        response = self.client.post(
            reverse('accounts:password_reset'), form_data)
        self.assertRedirects(response, reverse('accounts:login'))
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue('http://' in mail.outbox[0].body)
        self.assertEqual(
            settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)

Example 20

Project: django-contact-form
Source File: test_forms.py
View license
    def test_send(self):
        """
        Valid form can and does in fact send email.

        """
        form = ContactForm(request=self.request(),
                           data=self.valid_data)
        self.assertTrue(form.is_valid())

        form.save()
        self.assertEqual(1, len(mail.outbox))

        message = mail.outbox[0]
        self.assertTrue(self.valid_data['body'] in message.body)
        self.assertEqual(settings.DEFAULT_FROM_EMAIL,
                         message.from_email)
        self.assertEqual(form.recipient_list,
                         message.recipients())

Example 21

Project: django-registration
Source File: views.py
View license
    def send_activation_email(self, user):
        """
        Send the activation email. The activation key is simply the
        username, signed using TimestampSigner.

        """
        activation_key = self.get_activation_key(user)
        context = self.get_email_context(activation_key)
        context.update({
            'user': user
        })
        subject = render_to_string(self.email_subject_template,
                                   context)
        # Force subject to a single line to avoid header-injection
        # issues.
        subject = ''.join(subject.splitlines())
        message = render_to_string(self.email_body_template,
                                   context)
        user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)

Example 22

Project: pytest_django
Source File: test_funcargs.py
View license
def test_settings(settings):
    assert settings.DEFAULT_FROM_EMAIL != '[email protected]', settings.DEFAULT_FROM_EMAIL
    settings.DEFAULT_FROM_EMAIL = '[email protected]'
    assert settings.DEFAULT_FROM_EMAIL == '[email protected]'
    from django.conf import settings as real_settings
    assert real_settings.DEFAULT_FROM_EMAIL == '[email protected]'

Example 23

Project: fixmydjango
Source File: views.py
View license
    def form_valid(self, form):
        response = super().form_valid(form)

        messages.info(self.request,
                      "Thank you for adding a new exception! "
                      "Soon its solution will be available.")
        draft_url = self.request.build_absolute_uri(
            reverse('admin:drafts_draft_change', args=[self.object.id]))
        send_templated_mail(
            template_name='new_draft',
            from_email=settings.DEFAULT_FROM_EMAIL,
            recipient_list=['[email protected]'],
            context={
                'draft': self.object,
                'draft_url': draft_url})

        return response

Example 24

Project: timebank
Source File: views.py
View license
    def POST(self):
        # check permissions
        if not self.request.user.is_staff or\
            not self.request.user.is_superuser:
            self.flash(_("You don't have permission to send an email to all"
                " users"))
            return redirect('main.views.index')

        form = SendEmailToAllForm(self.request.POST)
        if not form.is_valid():
            return self.context_response('user/send_email_to_all.html',
                {'form': form, 'current_tab': 'admin-panel'})

        mass_email = EmailMessage(form.cleaned_data["subject"], form.cleaned_data["message"],
            from_email=settings.DEFAULT_FROM_EMAIL, to=[],
            bcc=[user.email for user in Profile.objects.filter(is_active=True)])
        mass_email.send()
        self.flash(_("Email sent to all users"))
        return redirect('main.views.index')

Example 25

Project: foodnetwork
Source File: forms.py
View license
    def save(self):
        for user in User.objects.filter(email__iexact=self.cleaned_data["email"]):
            new_password = User.objects.make_random_password()
            user.set_password(new_password)
            user.save()
            subject = _("Password reset")
            message = render_to_string("account/password_reset_message.txt", {
                "user": user,
                "new_password": new_password,
            })
            send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email], priority="high")
        return self.cleaned_data["email"]

Example 26

Project: wger
Source File: send-mass-emails.py
View license
    def handle(self, **options):
        '''
        Send some mails and remove them from the list
        '''
        if CronEntry.objects.count():
            for email in CronEntry.objects.all()[:100]:
                mail.send_mail(email.log.subject,
                               email.log.body,
                               settings.DEFAULT_FROM_EMAIL,
                               [email.email],
                               fail_silently=True)
                email.delete()

Example 27

Project: wger
Source File: gym.py
View license
    def process_preview(self, request, form, context):
        '''
        Send an email to the managers with the current content
        '''
        for admin in Gym.objects.get_admins(self.gym.pk):
            if admin.email:
                mail.send_mail(form.cleaned_data['subject'],
                               form.cleaned_data['body'],
                               settings.DEFAULT_FROM_EMAIL,
                               [admin.email],
                               fail_silently=False)
        return context

Example 28

Project: hawkpost
Source File: tasks.py
View license
def send_email(user, subject, template):
    content = render_to_string(template, context={"user": user})
    email = EmailMultiAlternatives(subject, content,
                                   settings.DEFAULT_FROM_EMAIL,
                                   [user.email])
    email.send()

Example 29

Project: hawkpost
Source File: tasks.py
View license
@shared_task
def send_email_notification(subject, body, email):
    email = EmailMultiAlternatives(subject, body,
                                   settings.DEFAULT_FROM_EMAIL,
                                   [email])
    email.send()

Example 30

Project: django-herald
Source File: base.py
View license
    def get_sent_from(self):
        from_email = self.from_email
        if not from_email:
            from_email = settings.DEFAULT_FROM_EMAIL

        return from_email

Example 31

Project: zulip
Source File: deliver_email.py
View license
def get_sender_as_string(dictionary):
    # type: (Dict[str, str]) -> str
    if dictionary["sender_email"]:
        return dictionary["sender_email"] if not dictionary["sender_name"] else format_html(u"\"{0}\" <{1}>",
                                                                                            dictionary["sender_name"],
                                                                                            dictionary["sender_email"])
    return settings.DEFAULT_FROM_EMAIL

Example 32

Project: django-le-social
Source File: views.py
View license
    def send_notification(self):
        context = self.get_notification_context()
        send_mail(
            render_to_string(self.notification_subject_template_name,
                             context).strip(),
            render_to_string(self.notification_template_name, context),
            settings.DEFAULT_FROM_EMAIL,
            [self.user.email],
        )

Example 33

Project: django-password-reset
Source File: views.py
View license
    def send_notification(self):
        context = {
            'site': self.get_site(),
            'user': self.user,
            'username': get_username(self.user),
            'token': signing.dumps(self.user.pk, salt=self.salt),
            'secure': self.request.is_secure(),
        }
        body = loader.render_to_string(self.email_template_name,
                                       context).strip()
        subject = loader.render_to_string(self.email_subject_template_name,
                                          context).strip()
        send_mail(subject, body, settings.DEFAULT_FROM_EMAIL,
                  [self.user.email])

Example 34

Project: django-nonrel
Source File: views.py
View license
    def test_email_found(self):
        "Email is sent if a valid email address is provided for password reset"
        response = self.client.post('/password_reset/', {'email': '[email protected]'})
        self.assertEqual(response.status_code, 302)
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue("http://" in mail.outbox[0].body)
        self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)

Example 35

Project: write-it
Source File: confirmation_test.py
View license
    @override_settings(SEND_ALL_EMAILS_FROM_DEFAULT_FROM_EMAIL=True)
    def test_send_confirmation_from_a_single_email_address(self):
        '''
        In some cases it is needed that the email is sent from a single
        email, that email should be the default_from_email
        '''
        Confirmation.objects.create(message=self.message)
        expected_from_email = settings.DEFAULT_FROM_EMAIL
        self.assertEquals(mail.outbox[0].from_email, expected_from_email)

Example 36

Project: hue
Source File: test_views.py
View license
    @override_settings(ALLOWED_HOSTS=['adminsite.com'])
    def test_admin_reset(self):
        "If the reset view is marked as being for admin, the HTTP_HOST header is used for a domain override."
        response = self.client.post('/admin_password_reset/',
            {'email': '[email protected]'},
            HTTP_HOST='adminsite.com'
        )
        self.assertEqual(response.status_code, 302)
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue("http://adminsite.com" in mail.outbox[0].body)
        self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)

Example 37

Project: django-secure-login
Source File: on_fail.py
View license
def email_user(username, password, **kwargs):
    try:
        user = User.objects.get(username=username)
        message = render_to_string("secure_login/failed_login_user.txt")
        send_mail("failed_login",
                  message,
                  settings.DEFAULT_FROM_EMAIL,
                  [user.email])

    except User.DoesNotExist:
        pass

Example 38

Project: decode-Django
Source File: views.py
View license
    def test_email_found(self):
        "Email is sent if a valid email address is provided for password reset"
        response = self.client.post('/password_reset/', {'email': '[email protected]'})
        self.assertEqual(response.status_code, 302)
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue("http://" in mail.outbox[0].body)
        self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)

Example 39

Project: blue-channel
Source File: models.py
View license
    def send_confirmation(self, email_address):
        salt = sha.new(str(random())).hexdigest()[:5]
        confirmation_key = sha.new(salt + email_address.email).hexdigest()
        current_site = Site.objects.get_current()
        activate_url = u"http://%s%s" % (
            unicode(current_site.domain),
            reverse("emailconfirmation.views.confirm_email", args=(confirmation_key,))
        )
        context = {
            "user": email_address.user,
            "activate_url": activate_url,
            "current_site": current_site,
            "confirmation_key": confirmation_key,
        }
        subject = render_to_string("emailconfirmation/email_confirmation_subject.txt", context)
        message = render_to_string("emailconfirmation/email_confirmation_message.txt", context)
        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [email_address.email], priority="high")
        
        return self.create(email_address=email_address, sent=datetime.now(), confirmation_key=confirmation_key)

Example 40

Project: storybase
Source File: models.py
View license
@receiver(post_save, sender=SiteContactMessage)
def send_message_to_admins(sender, **kwargs):
    """Send a copy of the message to admins"""
    from django.template.loader import render_to_string 

    instance = kwargs.get('instance')
    subject = _("New message from") + " " + instance.email
    message = render_to_string('storybase_messaging/sitecontactmessage_email.txt',
                               { 'message': instance })
    send_admin_mail(subject, message, settings.DEFAULT_FROM_EMAIL)

Example 41

Project: storybase
Source File: models.py
View license
    def get_email(self):
        """
        Returns an ``EmailMultiAlternatives`` object for the story 
        notification message
        """
        subject = self.get_subject()
        from_email = settings.DEFAULT_FROM_EMAIL
        to = self.story.author.email
        text_content = self.get_text_content()
        html_content = self.get_html_content()
        email = EmailMultiAlternatives(subject, text_content, from_email, [to])
        if html_content:
            email.attach_alternative(html_content, "text/html")
        return email 

Example 42

Project: django
Source File: test_deprecated_views.py
View license
    def test_email_found(self):
        "Email is sent if a valid email address is provided for password reset"
        response = self.client.post('/password_reset/', {'email': '[email protected]'})
        self.assertEqual(response.status_code, 302)
        self.assertEqual(len(mail.outbox), 1)
        self.assertIn("http://", mail.outbox[0].body)
        self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)
        # optional multipart text/html email has been added.  Make sure original,
        # default functionality is 100% the same
        self.assertFalse(mail.outbox[0].message().is_multipart())

Example 43

View license
    def send(self, **kwargs):
        subject = kwargs.get('subject', None)
        message = kwargs.get('message', None)
        recipient_list = kwargs.get('recipient_list', None)

        send_mail(subject=subject,
                  message=message,
                  from_email=settings.DEFAULT_FROM_EMAIL,
                  recipient_list=recipient_list,
                  fail_silently=True)

Example 44

View license
    def send(self, datatuples, **kwargs):
        send_mass_mail(
            tuple(tuple(
                d.get('subject', None),
                d.get('message', None),
                settings.DEFAULT_FROM_EMAIL,
                d.get('recipient_list', None))
                for d in datatuples),
            fail_silently=True)

Example 45

Project: ecobasa
Source File: mail_patch_postman.py
View license
def email(subject_template, message_template, recipient_list, object):
    """Compose and send an email."""
    ctx_dict = {'site': Site.objects.get_current(), 'object': object, 'action': 'acceptance'}
    subject = render_to_string(subject_template, ctx_dict)
    # Email subject *must not* contain newlines
    subject = ''.join(subject.splitlines())
    message = render_to_string(message_template, ctx_dict)
    # during the development phase, consider using the setting: EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
    send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)

Example 46

Project: edx-platform
Source File: test_email.py
View license
    def assertEmailUser(self, email_user, subject_template, subject_context, body_template, body_context):
        """Assert that `email_user` was used to send and email with the supplied subject and body

        `email_user`: The mock `django.contrib.auth.models.User.email_user` function
            to verify
        `subject_template`: The template to have been used for the subject
        `subject_context`: The context to have been used for the subject
        `body_template`: The template to have been used for the body
        `body_context`: The context to have been used for the body
        """
        email_user.assert_called_with(
            mock_render_to_string(subject_template, subject_context),
            mock_render_to_string(body_template, body_context),
            configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
        )

Example 47

Project: peer
Source File: expirationwarnings.py
View license
    def send_email(self, subject, recipients, context):
        if recipients:
            message = render_to_string(
                'entity/expiration_alert_to_owners.txt', context)
            send_mail(subject, message, settings.DEFAULT_FROM_EMAIL,
                      list(recipients), fail_silently=False)
        else:
            message = render_to_string(
                'entity/expiration_alert_to_admins.txt', context)
            mail_admins(subject, message, fail_silently=False)

Example 48

Project: peer
Source File: monitorentities.py
View license
def mail_problems(user, problems):
    context = {'problems': problems, 'site': Site.objects.get_current()}
    message = render_to_string('entity/endpoint_failures_alert.txt', context)
    subject = _("Some entity's endpoints are down")
    send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email],
              fail_silently=False)

Example 49

Project: happinesspackets
Source File: misc.py
View license
def send_html_mail(subject, body_txt, body_html, recipient):
    message = EmailMultiAlternatives(subject, body_txt, settings.DEFAULT_FROM_EMAIL, [recipient])
    message.attach_alternative(body_html, 'text/html')
    message.mixed_subtype = 'related'

    logo_file = open(settings.STATIC_ROOT.child('images').child('logo.png'))
    logo_mime = MIMEImage(logo_file.read())
    logo_file.close()
    logo_mime.add_header('Content-ID', '<[email protected]>')
    logo_mime.add_header('Content-Disposition', 'attachment')

    message.attach(logo_mime)
    message.send()

Example 50

Project: aldryn-events
Source File: utils.py
View license
def send_user_confirmation_email(registration, language):
    event = registration.event
    ctx = {
        'event_name': event.title,
        'first_name': registration.first_name,
        'event_url': u"http://%s%s" % (
            Site.objects.get_current(), event.get_absolute_url()
        ),
    }
    subject = render_to_string(
        template_name='aldryn_events/emails/registrant_confirmation.subject.txt',  # NOQA
        dictionary=ctx
    ).strip()
    body = render_to_string(
        template_name='aldryn_events/emails/registrant_confirmation.body.txt',
        dictionary=ctx
    )
    send_mail(subject, body, settings.DEFAULT_FROM_EMAIL,
              recipient_list=[registration.email])