django.core.mail.send_mail

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

200 Examples 7

Example 1

Project: talk.org
Source File: models.py
View license
  def email_user(self, subject, message, from_email):
    """Sends an email to this user.

    According to the App Engine email API the from_email must be the
    email address of a registered administrator for the application.
    """
    mail.send_mail(subject,
                   message,
                   from_email,
                   [self.email])

Example 2

Project: django-mailer
Source File: tests.py
View license
    def test_save_to_db(self):
        """
        Test that using send_mail creates a Message object in DB instead, when EMAIL_BACKEND is set.
        """
        self.assertEqual(Message.objects.count(), 0)
        with self.settings(EMAIL_BACKEND="mailer.backend.DbBackend"):
            mail.send_mail("Subject", "Body", "[email protected]", ["[email protected]"])
            self.assertEqual(Message.objects.count(), 1)

Example 3

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 4

Project: django-celery-email
Source File: tests.py
View license
    def test_sending_email(self):
        [result] = mail.send_mail('test', 'Testing with Celery! w00t!!', '[email protected]',
                                  ['[email protected]'])
        self.assertEqual(result.get(), 1)
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].subject, 'test')

Example 5

Project: django-outbox
Source File: test_outbox.py
View license
    def _send_mail(self, subject='Look at Foo!'):
        sleep(1)

        mail.send_mail(
                subject, 
                'Here is my Foo.', 
                '[email protected]',
                ['[email protected]'])

Example 6

Project: djangae
Source File: test_mail.py
View license
    @override_settings(EMAIL_BACKEND='djangae.mail.AsyncEmailBackend')
    def test_send_email_deferred(self):
        """ Test that sending an email using Django results in the email being sent through App
            Engine.
        """
        with sleuth.watch('djangae.mail.aeemail.EmailMessage.send') as gae_send:
            send_mail("Subject", "Hello", self._get_valid_sender_address(), ["[email protected]"])
            self.process_task_queues()
            self.assertTrue(gae_send.called)

Example 7

Project: pythondotorg
Source File: views.py
View license
    def form_valid(self, form):
        self.object = form.save(commit=False)
        if self.request.user.is_authenticated():
            self.object.creator = self.request.user
        self.object.save()

        # Send subscription email to mailing lists
        if settings.MAILING_LIST_PSF_MEMBERS and self.object.psf_announcements:
            send_mail(
                subject='PSF Members Announce Signup from python.org',
                message='subscribe',
                from_email=self.object.creator.email,
                recipient_list=[settings.MAILING_LIST_PSF_MEMBERS],
            )

        return super().form_valid(form)

Example 8

Project: pythondigest
Source File: mail.py
View license
def send_validation(strategy, backend, code):
    url = '{0}?verification_code={1}'.format(reverse('social:complete',
                                                     args=(backend.name,)),
                                             code.code)
    url = strategy.request.build_absolute_uri(url)
    send_mail('Validate your account', 'Validate your account {0}'.format(url),
              settings.EMAIL_FROM, [code.email],
              fail_silently=False)

Example 9

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 10

Project: rapidpro
Source File: email.py
View license
def send_temba_email(subject, text, html, from_email, recipient_list):
    """
    Actually sends the email. Having this as separate function makes testing multi-part emails easier
    """
    if settings.SEND_EMAILS:
        if html is not None:
            message = EmailMultiAlternatives(subject, text, from_email, recipient_list)
            message.attach_alternative(html, "text/html")
            message.send()
        else:
            send_mail(subject, text, from_email, recipient_list)
    else:
        # just print to console if we aren't meant to send emails
        print "----------- Skipping sending email, SEND_EMAILS to set False -----------"
        print text
        print "------------------------------------------------------------------------"

Example 11

Project: Resmin
Source File: __init__.py
View license
def send_email_from_template(template_name, recipients, context):
    e_subject_path = '%s/%s_subject.txt' % (
        settings.EMAIL_TEMPLATES_PREFIX, template_name)
    e_body_path = '%s/%s_body.txt' % (
        settings.EMAIL_TEMPLATES_PREFIX, template_name)

    e_subject = render_to_string(e_subject_path, context).replace('\n', '')
    e_body = render_to_string(e_body_path, context)

    send_mail(e_subject, e_body, settings.EMAIL_FROM, recipients)

Example 12

Project: ava
Source File: utils.py
View license
def send_mail_smtp(address_to, address_from, message_subject, message_body):
    logger.debug('Function called'
                 ' - utils::send_mail_smtp')
    if not send_mail(message_subject,
                     message_body,
                     address_from,
                     [address_to],
                     fail_silently=True):
        logger.debug('Function error'
                     ' - utils::send_mail_smtp'
                     ' - Failed to send mail')
        return False
    return True

Example 13

Project: ska
Source File: ska_callbacks.py
View license
    @staticmethod
    def _send_email(group_name, user, request, signed_request_data):
        """
        Custom callback for power users.
        """
        # Sending email to users
        email = signed_request_data.get('email', '')
        first_name = signed_request_data.get('first_name', '')
        if email:
            send_mail(
                _('Welcome!'),
                _("""Dear {0}\nYou have been added to the group power users.\nBest regards""").format(first_name),
                '[email protected]',
                [email],
                fail_silently=True
                )

Example 14

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 15

Project: seriesly
Source File: models.py
View license
    def send_confirmation_mail(self):
        confirmation_key = self.get_signed_email()
        confirmation_url = settings.DOMAIN_URL + reverse("seriesly-subscription-confirm_mail", args=(self.subkey, confirmation_key))

        sub_url = settings.DOMAIN_URL + reverse("seriesly-subscription-show", args=(self.subkey,))

        subject = "Confirm your seriesly.com email notifications"
        body = """Please confirm your email notifications for your favorite TV-Shows by clicking the link below:

%s

You will only receive further emails when you click the link.
If you did not expect this mail, you should ignore it.
By the way: your Seriesly subscription URL is: %s
    """ % (confirmation_url, sub_url)
        mail.send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, [self.email])

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-locksmith
Source File: views.py
View license
def send_key_email(key, email_template):
    email_msg = render_to_string(email_template, {'key': key, 'LOCKSMITH_BASE_TEMPLATE': settings.LOCKSMITH_BASE_TEMPLATE})
    email_subject = getattr(settings, 'LOCKSMITH_EMAIL_SUBJECT',
                            'API Registration')
    send_mail(email_subject, email_msg, settings.DEFAULT_FROM_EMAIL,
              [key.email])

Example 19

Project: hubplus
Source File: models.py
View license
    def message(self, sender, subject, body) :

        if self.get_user() :
            return self.get_user().message(sender, subject, body)
        else :
            from messages.models import Message
            from django.core.mail import send_mail
            message = _("""

%(sender)s has sent you a new message from %(site_name)s .

%(body)s

""") % {'site_name':settings.SITE_NAME, 'body':body,  'sender':sender.get_display_name()}

            send_mail(subject, message, settings.SUPPORT_EMAIL, [self.email_address],fail_silently=True)
            return False

Example 20

Project: python-postmark
Source File: forms.py
View license
    def save(self, fail_silently=False):
        """
        Build and send the email message.
        """
        send_mail(subject=unicode(ugettext_lazy(self.cleaned_data['subject'])),
                  message=self.cleaned_data['body'], 
                  from_email=self.cleaned_data['sender'],
                  recipient_list=[addr.strip() for addr in self.cleaned_data['to'].split(',')],
                  fail_silently=fail_silently)

Example 21

Project: django-profile
Source File: models.py
View license
    def resend(self):
        """
        Resend validation email
        """
        template_body = "userprofile/email/validation.txt"
        template_subject = "userprofile/email/validation_subject.txt"
        site_name, domain = Site.objects.get_current().name, Site.objects.get_current().domain
        key = self.key
        body = loader.get_template(template_body).render(Context(locals()))
        subject = loader.get_template(template_subject).render(Context(locals())).strip()
        send_mail(subject=subject, message=body, from_email=None, recipient_list=[self.email])
        self.created = datetime.datetime.now()
        self.save()
        return True

Example 22

Project: django-post_office
Source File: test_backends.py
View license
    @override_settings(
        EMAIL_BACKEND='post_office.EmailBackend',
        POST_OFFICE={
            'DEFAULT_PRIORITY': 'now',
            'BACKENDS': {'default': 'django.core.mail.backends.dummy.EmailBackend'}
        }
    )
    def test_default_priority_now(self):
        # If DEFAULT_PRIORITY is "now", mails should be sent right away
        send_mail('Test', 'Message', '[email protected]', ['[email protected]'])
        email = Email.objects.latest('id')
        self.assertEqual(email.status, STATUS.sent)

Example 23

Project: acacia_main
Source File: collect.py
View license
def send_downgrade_email(customer):
    from django.core.mail import send_mail
    from django.template.loader import render_to_string

    email_content = render_to_string(
        "billing/email_downgrade.txt",
        context={"username":customer.user.username}
    )

    result = send_mail(
        'Acacia Account Downgraded',
        email_content,
        '[email protected]',
        [customer.user.email],
        fail_silently=True
    )
    return result == 1

Example 24

View license
def send_email(email, new_password):
    if settings.EMAIL_HOST_USER is '' or settings.EMAIL_HOST_PASSWORD is '':
        return {'status' : 'failed', 'message' : 'cannot change password, emailer is offline, please check back later' }
    
    text = "Your new password is: " + new_password
            
    send_mail(
        "New Password",
        text,
        settings.EMAIL_HOST_USER,
        [email],
        fail_silently=False
    )
    return {'status' : 'success', 'message' : 'successfully registered' }

Example 25

Project: Djrill
Source File: test_mandrill_subaccounts.py
View license
    @override_settings(MANDRILL_SUBACCOUNT="legacy_setting_subaccount")
    def test_subaccount_legacy_setting(self):
        mail.send_mail('Subject', 'Body', '[email protected]', ['[email protected]'])
        data = self.get_api_call_data()
        self.assertEqual(data['message']['subaccount'], "legacy_setting_subaccount")

        message = mail.EmailMessage('Subject', 'Body', '[email protected]', ['[email protected]'])
        message.subaccount = "individual_message_subaccount"  # should override legacy setting
        message.send()
        data = self.get_api_call_data()
        self.assertEqual(data['message']['subaccount'], "individual_message_subaccount")

Example 26

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 27

Project: django-timepiece
Source File: models.py
View license
    def _send_mail(self, subject, ctx):
        # Don't go to the work unless we have a place to send it
        emails = utils.get_setting('TIMEPIECE_ACCOUNTING_EMAILS')
        if not emails:
            return
        from_email = utils.get_setting('DEFAULT_FROM_EMAIL')
        msg = render_to_string('timepiece/contract/hours_email.txt', ctx)
        send_mail(
            subject=subject,
            message=msg,
            from_email=from_email,
            recipient_list=emails
        )

Example 28

Project: canvas
Source File: api.py
View license
@api('deactivate')
@require_user
def deactivate_user(request):
    """ Sends us an email. """
    subject = "User deactivation request ({})".format(request.user.username)
    admin_url = 'http://example.com/admin/api_console'
    message = "{}\n\n{}\n\n{}".format(request.user.username, request.user.email, admin_url)
    from_ = "[email protected]"
    to = "[email protected]"
    send_mail(subject, message, from_, [to])

Example 29

Project: cgstudiomap
Source File: sendtestemail.py
View license
    def handle(self, *args, **kwargs):
        subject = 'Test email from %s on %s' % (socket.gethostname(), timezone.now())

        send_mail(
            subject=subject,
            message="If you\'re reading this, it was successful.",
            from_email=None,
            recipient_list=kwargs['email'],
        )

        if kwargs['managers']:
            mail_managers(subject, "This email was sent to the site managers.")

        if kwargs['admins']:
            mail_admins(subject, "This email was sent to the site admins.")

Example 30

Project: indivo_server
Source File: utils.py
View license
def send_mail(subject, body, sender, recipient_list):
    # if send mail?
    if settings.SEND_MAIL:
        try:
            mail.send_mail(subject, body, sender, recipient_list)
        except Exception, e:
            logging.error("Exception raised when trying to send the following email: %s" % e)
            logging.error("-----\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n-----" % (sender, ', '.join(recipient_list), subject, body))
            raise e
    else:
        logging.debug("send_mail to set to false, would have sent email to %s\n\n%s" % (', '.join(recipient_list), body))

Example 31

Project: dj-dynamic-forms
Source File: actions.py
View license
@formmodel_action(ugettext('Send via email'))
def dynamic_form_send_email(form_model, form):
    mapped_data = form.get_mapped_data()

    subject = _('Form ā€œ%(formname)sā€ submitted') % {'formname': form_model}
    message = render_to_string('dynamic_forms/email.txt', {
        'form': form_model,
        'data': sorted(mapped_data.items()),
    })
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient_list = settings.DYNAMIC_FORMS_EMAIL_RECIPIENTS
    send_mail(subject, message, from_email, recipient_list)

Example 32

Project: google-app-engine-django
Source File: models.py
View license
  def email_user(self, subject, message, from_email):
    """Sends an email to this user.

    According to the App Engine email API the from_email must be the
    email address of a registered administrator for the application.
    """
    mail.send_mail(subject,
                   message,
                   from_email,
                   [self.email])

Example 33

Project: hue
Source File: moderation.py
View license
    def email(self, comment, content_object, request):
        """
        Send email notification of a new comment to site staff when email
        notifications have been requested.

        """
        if not self.email_notification:
            return
        recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS]
        t = loader.get_template('comments/comment_notification_email.txt')
        c = Context({ 'comment': comment,
                      'content_object': content_object })
        subject = '[%s] New comment posted on "%s"' % (get_current_site(request).name,
                                                          content_object)
        message = t.render(c)
        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)

Example 34

View license
def send_event_report_email(user, event):
    template = loader.get_template("mailer/event_email.txt")
    context = Context({'user': user, 'event': event})

    txt_content = template.render(context)

    send_mail('A new event on codeweek.eu needs your attention',
              txt_content, "[email protected]", [user.email])

Example 35

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 36

Project: django-socialnews
Source File: accounts.py
View license
    def get(self, request, username):
        user = User.objects.get(username=username)
        try:
            key = PasswordResetKey.objects.get(user = user)
        except PasswordResetKey.DoesNotExist:
            return HttpResponseForbidden('The key you provided was wrong. Your password could not be reset.')
        request_key = request.GET.get('key', '')
        if request_key == key.key:
            password = helpers.generate_random_key()
            user.set_password(password)
            mail_text = render_to_string('registraion/password_reset_done.txt', dict(user=user, password=password))
            send_mail('Password reset', mail_text, '[email protected]', [user.email])
            key.delete()
            payload = {}
            return render(request, payload, 'registration/password_reset_done.html')
        else:
            return HttpResponseForbidden('The key you provided was wrong. Your password could nit be reset.')

Example 37

Project: decode-Django
Source File: moderation.py
View license
    def email(self, comment, content_object, request):
        """
        Send email notification of a new comment to site staff when email
        notifications have been requested.

        """
        if not self.email_notification:
            return
        recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS]
        t = loader.get_template('comments/comment_notification_email.txt')
        c = Context({ 'comment': comment,
                      'content_object': content_object })
        subject = '[%s] New comment posted on "%s"' % (get_current_site(request).name,
                                                          content_object)
        message = t.render(c)
        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)

Example 38

Project: django
Source File: sendtestemail.py
View license
    def handle(self, *args, **kwargs):
        subject = 'Test email from %s on %s' % (socket.gethostname(), timezone.now())

        send_mail(
            subject=subject,
            message="If you\'re reading this, it was successful.",
            from_email=None,
            recipient_list=kwargs['email'],
        )

        if kwargs['managers']:
            mail_managers(subject, "This email was sent to the site managers.")

        if kwargs['admins']:
            mail_admins(subject, "This email was sent to the site admins.")

Example 39

Project: django-oscar
Source File: views.py
View license
    def send_confirmation_email(self, real_email, user, password):
        msg = get_template('gateway/email.txt').render(Context({
            'email': user.email,
            'password': password
        }))
        send_mail('Dashboard access to Oscar sandbox',
                  msg, '[email protected]',
                  [real_email])

Example 40

Project: django-ses
Source File: backend.py
View license
    def test_return_path(self):
        '''
        Ensure that the 'source' argument sent into send_raw_email uses
        settings.AWS_SES_RETURN_PATH, defaults to from address.
        '''
        settings.AWS_SES_RETURN_PATH = None
        send_mail('subject', 'body', '[email protected]', ['[email protected]'])
        self.assertEqual(self.outbox.pop()['source'], '[email protected]')

Example 41

Project: djangogirls
Source File: community_mails.py
View license
def send_job_mail(subject, message_plain, message_html, recipient):
    send_from = "[email protected]"
    try:
        send_mail(
            subject,
            message_plain,
            send_from,
            [recipient, send_from],
            auth_user=settings.JOBS_EMAIL_USER,
            auth_password=settings.JOBS_EMAIL_PASSWORD,
            html_message=message_html,
        )
        send_status = 'Email to {0} has been sent.'.format(''.join(recipient))
    except SMTPException:
        send_status = 'Something went wrong: email to {0}  \
            has NOT been sent.'.format(
                ''.join(recipient)
            )
    return send_status

Example 42

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 43

Project: HealthStarter
Source File: sendtestemail.py
View license
    def handle(self, *args, **kwargs):
        subject = 'Test email from %s on %s' % (socket.gethostname(), timezone.now())

        send_mail(
            subject=subject,
            message="If you\'re reading this, it was successful.",
            from_email=None,
            recipient_list=kwargs['email'],
        )

        if kwargs['managers']:
            mail_managers(subject, "This email was sent to the site managers.")

        if kwargs['admins']:
            mail_admins(subject, "This email was sent to the site admins.")

Example 44

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])

Example 45

Project: django-blog-zinnia
Source File: moderator.py
View license
    def do_email_notification(self, comment, content_object, request):
        """
        Send email notification of a new comment to site staff.
        """
        site = Site.objects.get_current()
        template = loader.get_template(
            'comments/comment_notification_email.txt')
        context = {'comment': comment, 'site': site,
                   'protocol': PROTOCOL,
                   'content_object': content_object}
        subject = _('[%(site)s] New comment posted on "%(title)s"') % \
            {'site': site.name, 'title': content_object.title}
        message = template.render(context)
        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL,
                  self.mail_comment_notification_recipients,
                  fail_silently=not settings.DEBUG)

Example 46

Project: feedhq
Source File: views.py
View license
    def form_valid(self, form):
        token = signing.dumps(self.request.user.pk, salt='delete_account')
        url = reverse('destroy_confirm', args=[token])
        context = {
            'user': self.request.user,
            'url': url,
            'site': RequestSite(self.request),
            'scheme': 'https' if self.request.is_secure() else 'http',
        }
        body = loader.render_to_string('email/account_delete.txt', context)
        subject = _('FeedHQ account deletion request')
        send_mail(subject, body, settings.DEFAULT_FROM_EMAIL,
                  [self.request.user.email])
        return redirect('destroy_sent')

Example 47

Project: zipfelchappe
Source File: views.py
View license
    def send_info_mail(self, request):
        # send mail with payment info
        context = Context({'request': request, 'pledge': self.pledge})
        subject, message = render_mail('cod_wiretransfer', context)

        send_mail(
            subject, message, settings.DEFAULT_FROM_EMAIL,
            [self.pledge.backer.email], fail_silently=False)

Example 48

Project: lettuce
Source File: moderation.py
View license
    def email(self, comment, content_object, request):
        """
        Send email notification of a new comment to site staff when email
        notifications have been requested.

        """
        if not self.email_notification:
            return
        recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS]
        t = loader.get_template('comments/comment_notification_email.txt')
        c = Context({ 'comment': comment,
                      'content_object': content_object })
        subject = '[%s] New comment posted on "%s"' % (Site.objects.get_current().name,
                                                          content_object)
        message = t.render(c)
        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)

Example 49

Project: geonode
Source File: email.py
View license
@task(name='geonode.tasks.email.send_email', queue='email')
def send_email(*args, **kwargs):
    """
    Sends an email using django's send_mail functionality.
    """

    send_mail(*args, **kwargs)

Example 50

Project: synnefo
Source File: notifications.py
View license
    def send(self):
        try:
            send_mail(
                self.subject,
                self.message,
                self.sender,
                self.recipients,
                connection=get_connection())
        except (SMTPException, socket.error), e:
            logger.exception(e)
            raise NotificationError(self)