예제 #1
0
파일: models.py 프로젝트: lintaba/eestecnet
    def save(self,
             force_insert=False,
             force_update=False,
             using=None,
             update_fields=None):
        if not self.date:
            self.date = timezone.now()
        if self.target.deadline:
            if self.target.deadline < self.date:
                return
        if self.target.category == "recruitment":
            if self.accepted:
                membership, created = Membership.objects.get_or_create(
                    team=self.target.organizing_committee.all()[0],
                    user=self.applicant)
                membership.save()
                self.delete()

            else:
                super(Application, self).save()
        else:
            if not self.pk:
                if self.target.questionaire:
                    self.questionaire = create_answer_set(
                        self.target.questionaire)
                message = MailerMessage()
                message.subject = "Hey hey! Just dropping by to tell you that" + \
                                  str(self.applicant) + " has applied to the event " + \
                                  str(self.target.name) + "\n Please remember to send " \
                                                          "a " \
                                                          "priority list."
                message.from_address = "noreply@eestecnet",
                message.to_address = ", ".join(
                    user.email for user in self.applicant.lc()[0].privileged())
                message.save()
            if self.accepted:
                participation, created = Participation.objects.get_or_create(
                    target=self.target, participant=self.applicant)
                participation.save()
                message = MailerMessage()
                context = {
                    'user': participation.participant,
                    'slug': participation.target.slug,
                }
                body = render_to_string("events/confirmation_email.txt",
                                        context)
                message.subject = "Congratulations! You were accepted to " + \
                                  participation.target.name
                message.content = body
                message.to_address = self.applicant.email
                message.save()
                len(MailerMessage.objects.all())
                logger.info(
                    str(self.applicant) + "was just accepted to " +
                    str(self.target))

                self.delete()
            else:
                super(Application, self).save()
예제 #2
0
파일: models.py 프로젝트: arpheno/eestecnet
    def save(self, force_insert=False, force_update=False, using=None,
             update_fields=None):
        if not self.date:
            self.date = timezone.now()
        if self.target.deadline:
            if self.target.deadline < self.date:
                return
        if self.target.category == "recruitment":
            if self.accepted:
                membership, created = Membership.objects.get_or_create(
                    team=self.target.organizing_committee.all()[0],
                    user=self.applicant
                )
                membership.save()
                self.delete()

            else:
                super(Application, self).save()
        else:
            if not self.pk:
                if self.target.questionaire:
                    self.questionaire = create_answer_set(self.target.questionaire)
                message = MailerMessage()
                message.subject = "[EESTEC] " + str(
                    self.applicant) + " applied to " + str(self.target.name)
                message.content = "Hey hey! Just dropping by to tell you that " + \
                                  str(self.applicant) + " has applied to the event " + \
                                  str(self.target.name) + "\nPlease remember to send " \
                                                          "a " \
                                                          "priority list."
                message.from_address = "noreply@eestecnet"
                message.to_address = ", ".join(
                    user.email for user in self.applicant.lc()[0].privileged())
                message.save()
            if self.accepted:
                participation, created = Participation.objects.get_or_create(
                    target=self.target,
                                                             participant=self.applicant)
                participation.save()
                message = MailerMessage()
                context = {
                    'user': participation.participant,
                    'slug': participation.target.slug,
                    }
                body = render_to_string("events/confirmation_email.txt",context)
                message.subject = "Congratulations! You were accepted to " + \
                                  participation.target.name
                message.content = body
                message.to_address = self.applicant.email
                message.save()
                len(MailerMessage.objects.all())
                logger.info(
                    str(self.applicant) + "was just accepted to " + str(self.target))

                self.delete()
            else:
                super(Application, self).save()
예제 #3
0
파일: views.py 프로젝트: arpheno/eestecnet
    def form_valid(self, form):
        user = form.save(commit=False)
        logger.info(str(user) + " registered on the website.")
        user.is_active = False
        user.activation_link = id_generator(30)
        user.first_name=user.first_name.strip()
        user.middle_name=user.middle_name.strip()
        user.last_name=user.last_name.strip()
        user.email = user.email.strip()

        message = MailerMessage()
        context = {
            'site': RequestSite(self.request),
            'user': user,
            'username': get_username(user),
            'secure': self.request.is_secure(),
            "activation_link": user.activation_link
        }
        message.subject = "Registration"
        message.content = render_to_string("account/registration.html", context)
        message.from_address = "*****@*****.**"
        message.to_address = user.email
        message.save()
        user.save()
        messages.add_message(
            self.request,
            messages.INFO,
            'Registration successful. Please check your email to complete the process.')
        return super(EestecerCreate, self).form_valid(form)
예제 #4
0
def send_mail(subject, content, from_addres, to_address):
    new_message = MailerMessage()
    new_message.subject = subject
    new_message.content = content
    new_message.from_addres = from_addres
    new_message.to_address = to_address
    new_message.save()
예제 #5
0
def dynamic_form_send_confirmation_email(form_model, form, advert, request):
    from django.template import Template, Context

    ctx = {"ad": advert, "advert": advert}

    if advert.confirmation_email_subject:
        subject = Template(advert.confirmation_email_subject).render(Context(ctx))
    else:
        subject = advert.title
    if advert.confirmation_email:
        message = Template(advert.confirmation_email).render(Context(ctx))
    else:
        message = render_to_string("dynamic_forms/confirmation_email.txt", ctx)

    new_message = MailerMessage()
    new_message.subject = subject
    new_message.to_address = form.cleaned_data["email"]
    new_message.bcc_address = (
        "%s, [email protected]" % advert.advertiser.roof_contact
    )  # settings.DYNAMIC_FORMS_EMAIL_HIDDEN_RECIPIENTS
    new_message.reply_to = advert.advertiser.email
    new_message.from_address = "*****@*****.**"
    new_message.from_name = "Roof Media"
    new_message.content = ""
    new_message.html_content = message
    new_message.app = "dynamic_forms"
    new_message.save()
예제 #6
0
def dynamic_form_send_email(form_model, form, advert, request):

    mapped_data = form.get_mapped_data()

    ctx = {"form_model": form_model, "form": form, "data": sorted(mapped_data.items()), "ad": advert}
    if advert.notification_email_subject:
        subject = Template(advert.notification_email_subject).render(Context(ctx))
    else:
        subject = _("Has recibido una nueva oportunidad de venta")
    if advert.notification_email:

        message = Template(advert.notification_email).render(Context(ctx))

    else:

        message = render_to_string("dynamic_forms/notification_email.txt", ctx)

    new_message = MailerMessage()
    new_message.subject = subject
    new_message.to_address = advert.advertiser.email
    new_message.bcc_address = (
        "%s, [email protected]" % advert.advertiser.roof_contact
    )  # settings.DYNAMIC_FORMS_EMAIL_HIDDEN_RECIPIENTS
    new_message.from_address = "*****@*****.**"
    new_message.from_name = "Roof Media"
    new_message.content = ""
    new_message.html_content = message
    new_message.app = "dynamic_forms"
    new_message.save()
예제 #7
0
    def send_mail(self, recipient, convention=None):
        if not convention:
            convention = self.trigger().convention

        context = Context({
            'recipient': recipient,
            'convention': convention,
        })
        subject_template = Template(self.subject)
        body_template = Template(
            '{body}\n-- \n{signature}'.format(
                body=self.body_text,
                signature=convention.mail_signature,)
        )
        email_subject = subject_template.render(context)
        email_body = body_template.render(context)

        from mailqueue.models import MailerMessage

        new_message = MailerMessage()
        new_message.subject = email_subject
        new_message.to_address = recipient.email
        new_message.content = email_body
        new_message.app = "ticket system"
        new_message.save()
예제 #8
0
def send_mail(subject, body, from_email, recipient_list, body_html=None, internal_sender_id=None):
    """
    Simplified version of the send_mail function which queues e-mails in the mail queue

    """

    mails = []

    for recipient in recipient_list:

        new_message = MailerMessage()
        new_message.subject = subject
        new_message.to_address = recipient
        new_message.from_address = from_email
        new_message.content = body

        if body_html is not None:
            new_message.html_content = body_html

        if internal_sender_id is None:
            new_message.app = "selvbetjening"
        else:
            new_message.app = internal_sender_id

        new_message.save()

        mails.append(new_message)

    return mails
예제 #9
0
    def send_email_visitor(self):
        # send email to requesting email
        # this method is called with cleaned from data
        subject = "Ihre Nachricht an mentoki"
        to = [self.cleaned_data['email']]
        from_mail = '*****@*****.**'

        # prepare template
        context = {
            'name': self.cleaned_data['name'],
            'email': self.cleaned_data['email'],
            'message': self.cleaned_data['message'],
            'betreff': "Ihre Nachricht",
        }
        message = get_template('email/contact/to_customer.html').render(
            Context(context))
        to_customer = MailerMessage()
        to_customer.subject = "Ihre Nachricht an mentoki"
        to_customer.to_address = self.cleaned_data['email']
        to_customer.from_address = ContactForm.CONTACT_EMAIL
        to_customer.content = ContactForm.OUTGOING
        to_customer.html_content = message
        to_customer.reply_to = ContactForm.CONTACT_EMAIL
        to_customer.app = self.__module__
        to_customer.save()
예제 #10
0
def send_email(to_address,
               subject,
               content,
               html_content,
               bcc_address=None,
               attachment=None,
               attachment2=None,
               attachment3=None):
    new_message = MailerMessage()
    new_message.subject = subject
    new_message.to_address = to_address

    if bcc_address:
        new_message.bcc_address = bcc_address

    new_message.from_address = settings.DEFAULT_FROM_EMAIL
    new_message.content = content
    new_message.html_content = html_content
    new_message.cc_address = settings.DEFAULT_CC_EMAIL
    if attachment:
        new_message.add_attachment(attachment)
    if attachment2:
        new_message.add_attachment(attachment2)
    if attachment3:
        new_message.add_attachment(attachment3)
    new_message.app = "our app name"
    new_message.save()
예제 #11
0
파일: models.py 프로젝트: arpheno/eestecnet
    def save(self, force_insert=False, force_update=False, using=None,
             update_fields=None):
        try:
            if self.category == "training":
                message = MailerMessage()
                context = { 'user': self.applicant, }
                body = render_to_string("events/training_tracker.txt", context)
                message.subject = " ".join(self.organizers.all())+"organized a training: " + self.target.name +"EOM"
                message.content = "end of message"
                message.to_address = "*****@*****.**"
                message.save()
        except:
            pass

        self.slug = slugify(self.name)
        if (self.feedbacksheet):
            if self.pk:
                # if created
                orig = Event.objects.get(pk=self.pk)
                if orig.feedbacksheet != self.feedbacksheet:
                    #if feedbacksheet has changed
                    for pax in self.participation_set.all():
                        if pax.feedback:
                            pax.feedback.delete()
                        pax.feedback = create_answer_set(self.feedbacksheet)
                        pax.save()
        if (self.questionaire):
            if self.pk:
                orig = Event.objects.get(pk=self.pk)
                if orig.questionaire != self.questionaire:
                    for application in self.applicants.all():
                        application.questionaire = create_answer_set(self.questionaire)
                        application.save()
        super(Event, self).save(force_insert, force_update, using, update_fields)
예제 #12
0
    def form_valid(self, form):
        user = form.save(commit=False)
        logger.info(str(user) + " registered on the website.")
        user.is_active = False
        user.activation_link = id_generator(30)
        user.first_name = user.first_name.strip()
        user.middle_name = user.middle_name.strip()
        user.last_name = user.last_name.strip()
        user.email = user.email.strip()

        message = MailerMessage()
        context = {
            'site': RequestSite(self.request),
            'user': user,
            'username': get_username(user),
            'secure': self.request.is_secure(),
            "activation_link": user.activation_link
        }
        message.subject = "Registration"
        message.content = render_to_string("account/registration.html",
                                           context)
        message.from_address = "*****@*****.**"
        message.to_address = user.email
        message.save()
        user.save()
        messages.add_message(
            self.request, messages.INFO,
            'Registration successful. Please check your email to complete the process.'
        )
        return super(EestecerCreate, self).form_valid(form)
예제 #13
0
파일: views.py 프로젝트: rhoerbe/ewtishop2
def users_confirm_password_reset(request,key,id):
	user = User.objects.get(pk=id)
	
	password_reset_token_cleartext = user.email + user.password + str(user.id)
	password_reset_token = hashlib.sha1(password_reset_token_cleartext).hexdigest()
	
	if key == password_reset_token:
		new_password = get_random_string(length=10)
		
		user.set_password( new_password )
		user.save()

		context = {'password': new_password,
				'email': user.email,
				'hostname': request.scheme + "://" + request.get_host(),
		}
		
		subject = render_to_string('ewtiusersite/email_users_confirm_password_reset/subject.txt', context)
		msg_text = render_to_string('ewtiusersite/email_users_confirm_password_reset/text.txt', context)
	
		new_message = MailerMessage()
		new_message.subject = subject
		new_message.to_address = user.email
		new_message.from_address = settings.EMAIL_SENDER_ADDRESS
		new_message.content = msg_text
		new_message.app = "EWTI Password Reset"
		new_message.save()
	
		return render_to_response('ewtiusersite/users_confirm_password_reset.html',
					{'hostname': request.scheme + "://" + request.get_host(),
					},
					context_instance=RequestContext(request))
		
	return HttpResponseRedirect(reverse('users_area'))	
예제 #14
0
파일: views.py 프로젝트: rhoerbe/ewtishop2
def registration_invoice_finish(request):
	from invoice.models import Invoice
	from bookings.models import BookingLine
	from mailqueue.models import MailerMessage
	from survey.actions import MailSenderParticipantSurvey


	session_invoice_id = request.session['paid_invoice_id']

	invoice = Invoice.objects.get(pk=session_invoice_id)
	receiver = invoice.address.billing_email

	survey_link = None
	billed_participant = invoice.billed_participant()

	context = {'handle': invoice.handle,
		'number': invoice.number,
		'hostname': request.scheme + "://" + request.get_host(),
		'receiver' : receiver,
		'billed_participant': billed_participant,
		}

	if not invoice.mail_sent_at:

		subject = render_to_string('ewtisite/email_invoice_paid/subject.txt', context)
		msg_text = render_to_string('ewtisite/email_invoice_paid/text.txt', context)
		#receiver = invoice.address.billing_email

		new_message = MailerMessage()
		new_message.subject = subject
		new_message.to_address = receiver
		new_message.from_address = settings.EMAIL_SENDER_ADDRESS
		new_message.bcc_address = settings.SHOP_NOTICE_MAILS_TO
		new_message.content = msg_text
		new_message.app = "EWTI Billing"
		new_message.save()

		entered_bookinglines = invoice.bookingline_set.all()
		for bl in entered_bookinglines:
			p = bl.participant

			ms = MailSenderParticipantSurvey()
			ms.context = {
				'participant':p,
				'hostname': request.scheme + "://" + request.get_host(),
				}
			ms.from_address = settings.EMAIL_SENDER_ADDRESS
			ms.bcc_address = settings.SHOP_NOTICE_MAILS_TO
			ms.to_address = p.email
			ms.send()

		invoice.mail_sent_at = datetime.now()
		invoice.save()



	return render(request, 'ewtisite/register_invoice_finish.html', context)
예제 #15
0
def sendmail(singername, receiver, title, url, time):
    new_message = MailerMessage()
    new_message.subject = singername + "演唱會資訊 from Hiticket"
    new_message.to_address = receiver
    new_message.bcc_address = ""
    new_message.from_address = "*****@*****.**"
    new_message.content = ""
    new_message.html_content = "哈囉, 有新的一筆關於" + singername + "演唱會的資料如下:<br><br> \n\n  時間:  " + time + "<br>\n  Title:  " + title + "<br>\n  Link:  " + url
    new_message.app = "Name of your App that is sending the email."
    new_message.save()
예제 #16
0
def create_mail_message():
    """Here gives email subject , to_address email id , from_address email id , content of messaage , html_contennt of message"""
    new_message = MailerMessage()
    new_message.subject = "My Subject"
    new_message.to_address = "*****@*****.**"
    new_message.from_address = "*****@*****.**"
    new_message.content = "Mail content"
    new_message.html_content = "<h1>Mail Content</h1>"
    new_message.app = "this is test email please ignore."
    new_message.save()
예제 #17
0
def send_email(sender, instance, created, **kwargs):
    if instance.source != 2 and created:
        message = render_to_string('analytics/saleoportunity_email.txt', {'sopt': instance})
        new_message = MailerMessage()
        new_message.subject = _('Has recibido una nueva oportunidad de venta')
        new_message.to_address = instance.ad.advertiser.email
        new_message.from_address = '*****@*****.**'
        new_message.from_name = 'Roof Media'
        new_message.html_content = message
        new_message.app = "analytics"
        new_message.save()
예제 #18
0
def create_mail_message(request):
    new_message = MailerMessage()
    new_message.subject = "My Subject"
    new_message.to_address = "*****@*****.**"
    new_message.bcc_address = "*****@*****.**"
    new_message.from_address = "*****@*****.**"
    new_message.content = "Mail content"
    new_message.html_content = "<h1>Mail Content</h1>"
    new_message.app = "Name of your App that is sending the email."
    new_message.save()

    return render(request, 'index.html')
예제 #19
0
파일: models.py 프로젝트: arpheno/eestecnet
 def delete(self, using=None):
     if not self.accepted:
         message = MailerMessage()
         context = { 'user': self.applicant, }
         body = render_to_string("events/rejection_email.txt",context)
         message.subject = "Your application to " + self.target.name
         message.content = body
         message.to_address = self.applicant.email
         message.save()
         logger.info(
             str(self.applicant) + "was just rejected from " + str(self.target))
         len(MailerMessage.objects.all())
     return super(Application,self).delete(using)
예제 #20
0
def send_greeting_email(instance, **kwargs):
    is_new = kwargs.get('created', None)
    if is_new:
        new_message = MailerMessage()
        new_message.subject = u"Спасибо за регистрацию!"
        new_message.to_address = instance.email
        # new_message.bcc_address = "*****@*****.**"
        new_message.from_address = "*****@*****.**"
        new_message.html_content = render_to_string('email/greeting.html')
        new_message.content = new_message.html_content
        # new_message.app = "Name of your App that is sending the email."
        new_message.do_not_send = True
        new_message.save()
예제 #21
0
 def _setup_email(self):
     msg = MailerMessage()
     msg.from_address = self.from_address
     msg.to_address = self._get_formatted_recipients(self.to)
     if self.cc:
         msg.cc_address = self._get_formatted_recipients(self.cc)
     full_bcc = self._get_bcc_with_debugging_copy()
     if full_bcc:
         msg.bcc_address = self._get_formatted_recipients(full_bcc)
     msg.subject = self.get_rendered_subject()
     msg.html_content = self.get_rendered_html_body()
     msg.content = self.get_plain_text_body()
     msg.app = self.mail.text_identifier
     return msg
예제 #22
0
def send_mail(subject, message, to, sender='*****@*****.**'):
    """
    Send an email
    :param subject: String subject of the email
    :param message: Text body of the email
    :param to: String email receiver
    :param sender: String email sender
    """
    mail = MailerMessage()
    mail.subject = subject
    mail.to_address = to
    mail.from_address = sender
    mail.html_content = message
    mail.app = 'Appetments'
    mail.save()
예제 #23
0
파일: views.py 프로젝트: Arkenjh/bv
	def get_email(self, request):

		from mailqueue.models import MailerMessage

		new_message = MailerMessage()
		new_message.subject = "oui c'est bien ce mail ..."
		new_message.to_address = "*****@*****.**"
		#new_message.bcc_address = "*****@*****.**"
		new_message.from_address = "*****@*****.**"
		new_message.content = "Mail content"
		new_message.html_content = "<h1>Mail Content</h1>"
		new_message.app = "Name of your App that is sending the email."
		new_message.save()

		return Response(new_message.html_content)
예제 #24
0
	def send(self):
		self.prepare_content()
		
		subject = self.content['Mailsubject']
		msg_text = self.content['Mailtext']
		
		new_message = MailerMessage()
		new_message.subject = subject
		new_message.to_address = self.to_address
		new_message.from_address = self.from_address
		if self.bcc_address:
			new_message.bcc_address = self.bcc_address
		new_message.content = msg_text
		new_message.app = "EWTI Survey Invitation"
		new_message.save()
예제 #25
0
def dynamic_form_send_download_email(form_model, form, advert, request):
    from content.models import DownloadLink
    import hashlib
    import random

    salt2 = "".join(["{0}".format(random.randrange(10)) for i in range(10)])
    key = hashlib.md5("{0}{1}".format(salt2, advert.file.name)).hexdigest()

    src = "/".join([settings.MEDIA_ROOT, advert.file.name])

    download_root = os.path.join(settings.MEDIA_ROOT, "downloads")
    download_url = os.path.join(settings.MEDIA_URL, "downloads")

    dst = os.path.join(download_root, key + ".pdf")
    dst_url = os.path.join(download_url, key + ".pdf")
    link = DownloadLink(key=key, ad=advert, url=dst_url, filepath=dst)
    site_url = request.build_absolute_uri("/")
    dl_url = site_url[:-1] + dst_url
    request.META["DL_URL"] = dl_url
    ctx = {"dl_url": dl_url, "ad": advert}

    if advert.confirmation_email_subject:
        subject = Template(advert.confirmation_email_subject).render(Context({"ad": advert}))
    else:
        subject = _("Descarga: “%(advert)s”") % {"advert": advert.title}
    if advert.confirmation_email:
        message = Template(advert.confirmation_email).render(Context(ctx))
    else:
        message = render_to_string("dynamic_forms/download_email.txt", ctx)

    new_message = MailerMessage()
    new_message.subject = subject
    new_message.to_address = form.cleaned_data["email"]
    new_message.bcc_address = (
        "%s, [email protected]" % advert.advertiser.roof_contact
    )  # settings.DYNAMIC_FORMS_EMAIL_HIDDEN_RECIPIENTS
    new_message.reply_to = advert.advertiser.email
    new_message.from_address = "*****@*****.**"
    new_message.from_name = "Roof Media"
    new_message.content = ""
    new_message.html_content = message
    new_message.app = "dynamic_forms"
    new_message.save()

    link.save()
    if not os.path.isdir(os.path.dirname(dst)):
        os.makedirs(os.path.dirname(dst))
    os.symlink(src, dst)
예제 #26
0
파일: views.py 프로젝트: xgeetx/eestecnet
def newsletter(request):
    try:
        validate_email(request.POST['mailsub'])
    except ValidationError:
        return redirect("/")
    messages.add_message(
        request, messages.INFO,
        'You have been subscribed. Please check your e-mail and also your spam folder.'
    )
    message = MailerMessage()
    message.subject = ""
    message.content = ""
    message.from_address = request.POST['mailsub']
    message.to_address = "*****@*****.**"
    message.save()
    return redirect("/")
예제 #27
0
파일: views.py 프로젝트: arpheno/eestecnet
def newsletter(request):
    try:
        validate_email( request.POST['mailsub'] )
    except ValidationError:
        return redirect("/")
    messages.add_message(
        request,
        messages.INFO,
        'You have been subscribed. Please check your e-mail and also your spam folder.')
    message=MailerMessage()
    message.subject = ""
    message.content = ""
    message.from_address = request.POST['mailsub']
    message.to_address = "*****@*****.**"
    message.save()
    return redirect("/")
예제 #28
0
파일: models.py 프로젝트: lintaba/eestecnet
 def delete(self, using=None):
     if not self.accepted:
         message = MailerMessage()
         context = {
             'user': self.applicant,
         }
         body = render_to_string("events/rejection_email.txt", context)
         message.subject = "Your application to " + self.target.name
         message.content = body
         message.to_address = self.applicant.email
         message.save()
         logger.info(
             str(self.applicant) + "was just rejected from " +
             str(self.target))
         len(MailerMessage.objects.all())
     return super(Application, self).delete(using)
예제 #29
0
 def form_valid(self, form):
     logger.info(
         str(self.request.user) +
         " just sent an email to all privileged members of the EESTEC Community: "
         + form.cleaned_data['message'])
     message = MailerMessage()
     message.subject = form.cleaned_data['subject']
     message.content = form.cleaned_data['message']
     message.from_address = "*****@*****.**"
     message.to_address = "*****@*****.**"
     message.bcc_address = ", ".join(
         user.email
         for user in Eestecer.objects.filter(groups__name="Local Admins"))
     message.save()
     messages.add_message(self.request, messages.INFO,
                          "Message will be sent now.")
     return redirect("/")
예제 #30
0
 def form_valid(self, form):
     logger.info(
         str(self.request.user) +
         " just sent an email to the whole EESTEC Community: " +
         form.cleaned_data['message'])
     message = MailerMessage()
     message.subject = form.cleaned_data['subject']
     message.content = form.cleaned_data['message']
     message.from_address = "*****@*****.**"
     message.to_address = "*****@*****.**"
     message.bcc_address = ", ".join(
         user.email
         for user in Eestecer.objects.filter(receive_eestec_active=True))
     message.save()
     messages.add_message(self.request, messages.INFO,
                          "Message will be sent now.")
     return redirect("/")
예제 #31
0
 def form_valid(self, form):
     logger.info(str(
         self.request.user) + " just sent an email to all privileged members of the EESTEC Community: " +
                 form.cleaned_data['message'])
     message = MailerMessage()
     message.subject = form.cleaned_data['subject']
     message.content = form.cleaned_data['message']
     message.from_address = "*****@*****.**"
     message.to_address = "*****@*****.**"
     message.bcc_address = ", ".join(
         user.email for user in Eestecer.objects.filter(groups__name="Local Admins"))
     message.save()
     messages.add_message(
         self.request,
         messages.INFO, "Message will be sent now."
     )
     return redirect("/")
예제 #32
0
 def form_valid(self, form):
     logger.info(str(
         self.request.user) + " just sent an email to the whole EESTEC Community: " +
                 form.cleaned_data['message'])
     message = MailerMessage()
     message.subject = form.cleaned_data['subject']
     message.content = form.cleaned_data['message']
     message.from_address = "*****@*****.**"
     message.to_address = "*****@*****.**"
     message.bcc_address = ", ".join(
         user.email for user in Eestecer.objects.filter(receive_eestec_active=True))
     message.save()
     messages.add_message(
         self.request,
         messages.INFO, "Message will be sent now."
     )
     return redirect("/")
예제 #33
0
파일: mailer.py 프로젝트: ortoloco/ortoloco
 def send(msg):
     tos = msg.to + msg.bcc
     for to in tos:
         new_message = MailerMessage()
         new_message.subject = msg.subject
         new_message.to_address = to
         new_message.from_address = msg.from_email
         new_message.content = msg.body
         if len(msg.alternatives) > 0:
             new_message.html_content = msg.alternatives[0][0]
         new_message.reply_to =  next(iter(msg.reply_to or []),None)
         for a in msg.attachments:
             with open(a[0], 'wb') as f:
                 f.write(a[1])
             at = File(open(a[0], 'rb'))
             new_message.add_attachment(at)
         new_message.save()
예제 #34
0
파일: forms.py 프로젝트: SEisme/frical
def send_contact_email(contact):
    to_address = settings.CONTACTS_EMAILS
    from_address = contact.email
    content = render_to_string("contacts/email_contact.txt", {'contact': contact})
    subject = render_to_string("contacts/email_contact_subject.txt", {'contact': contact})
    try:
        from mailqueue.models import MailerMessage
        msg = MailerMessage()
        msg.subject = subject
        msg.to_address = ", ".join(to_address)
        msg.from_address = from_address
        msg.content = content
        msg.app = 'Contacto'
        msg.send_mail()
    except ImportError:
        from django.core.mail import EmailMultiAlternatives
        msg = EmailMultiAlternatives(subject, content, from_address, to_address)
        msg.send()
예제 #35
0
    def test_mail_sending(self):

        from mailqueue.models import MailerMessage

        new_message = MailerMessage()
        new_message.subject = "Your test worked."
        new_message.to_address = os.environ['EMAIL_TEST_RECIPIENT']

        # if using Google SMTP, the actual from address will be settings.EMAIL_HOST_USER
        new_message.from_address = "*****@*****.**"

        new_message.content = "Your mail was successfully transmitted at {} Z".format(datetime.datetime.utcnow())

        # Note: HTML content supersedes plain content on Google messages
        new_message.html_content = "<h1>This is HTML Mail Content</h1><br>{}".format(new_message.content)

        new_message.app = "SAM Reports"
        new_message.save()
        assert True  # always passes if it does not crash
예제 #36
0
    def save(self,
             force_insert=False,
             force_update=False,
             using=None,
             update_fields=None):
        try:
            if self.category == "training":
                message = MailerMessage()
                context = {
                    'user': self.applicant,
                }
                body = render_to_string("events/training_tracker.txt", context)
                message.subject = " ".join(self.organizers.all(
                )) + "organized a training: " + self.target.name + "EOM"
                message.content = "end of message"
                message.to_address = "*****@*****.**"
                message.save()
        except:
            pass

        self.slug = slugify(self.name)
        if (self.feedbacksheet):
            if self.pk:
                # if created
                orig = Event.objects.get(pk=self.pk)
                if orig.feedbacksheet != self.feedbacksheet:
                    #if feedbacksheet has changed
                    for pax in self.participation_set.all():
                        if pax.feedback:
                            pax.feedback.delete()
                        pax.feedback = create_answer_set(self.feedbacksheet)
                        pax.save()
        if (self.questionaire):
            if self.pk:
                orig = Event.objects.get(pk=self.pk)
                if orig.questionaire != self.questionaire:
                    for application in self.applicants.all():
                        application.questionaire = create_answer_set(
                            self.questionaire)
                        application.save()
        super(Event, self).save(force_insert, force_update, using,
                                update_fields)
예제 #37
0
파일: models.py 프로젝트: airsoull/Leyere
def send_email_by_favorite_story(sender, instance, created, **kwargs):
    if created:
        from django.template.loader import render_to_string
        subject = _('Han marcado como favorita una de tus historias') + ' - ' + 'Leyere.com'
        from_address = settings.EMAIL_DEFAULT
        to_address = instance.follow_object.user.email
        content = render_to_string("actstream/email/email_favorite.txt", {'favorite': instance})
        try:
            from mailqueue.models import MailerMessage
            msg = MailerMessage()
            msg.subject = subject
            msg.to_address = to_address
            msg.from_address = from_address
            msg.content = content
            msg.app = 'Favorite Story'
            msg.send_mail()
        except ImportError:
            from django.core.mail import EmailMultiAlternatives
            msg = EmailMultiAlternatives(subject, content, from_address, to_address)
            msg.send()
예제 #38
0
    def test_mail_sending(self):

        from mailqueue.models import MailerMessage

        new_message = MailerMessage()
        new_message.subject = "Your test worked."
        new_message.to_address = os.environ['EMAIL_TEST_RECIPIENT']

        # if using Google SMTP, the actual from address will be settings.EMAIL_HOST_USER
        new_message.from_address = "*****@*****.**"

        new_message.content = "Your mail was successfully transmitted at {} Z".format(
            datetime.datetime.utcnow())

        # Note: HTML content supersedes plain content on Google messages
        new_message.html_content = "<h1>This is HTML Mail Content</h1><br>{}".format(
            new_message.content)

        new_message.app = "SAM Reports"
        new_message.save()
        assert True  # always passes if it does not crash
예제 #39
0
파일: forms.py 프로젝트: kdszyubin/frical
def send_contact_email(contact):
    to_address = settings.CONTACTS_EMAILS
    from_address = contact.email
    content = render_to_string("contacts/email_contact.txt",
                               {'contact': contact})
    subject = render_to_string("contacts/email_contact_subject.txt",
                               {'contact': contact})
    try:
        from mailqueue.models import MailerMessage
        msg = MailerMessage()
        msg.subject = subject
        msg.to_address = ", ".join(to_address)
        msg.from_address = from_address
        msg.content = content
        msg.app = 'Contacto'
        msg.send_mail()
    except ImportError:
        from django.core.mail import EmailMultiAlternatives
        msg = EmailMultiAlternatives(subject, content, from_address,
                                     to_address)
        msg.send()
예제 #40
0
파일: models.py 프로젝트: airsoull/Leyere
def send_email_by_comment(sender, instance, created, **kwargs):
    if created:
        if instance.user.profile.email_comment:
            from django.template.loader import render_to_string
            subject = _('Nuevo Comentario') + ' - ' + 'Leyere.com' 
            from_address = settings.EMAIL_DEFAULT
            to_address = instance.user_email
            content = render_to_string("comments/email/email_comment.txt", {'comment': instance})
            try:
                from mailqueue.models import MailerMessage
                msg = MailerMessage()
                msg.subject = subject
                msg.to_address = to_address
                msg.from_address = from_address
                msg.content = content
                msg.app = 'Comment'
                msg.send_mail()
            except ImportError:
                from django.core.mail import EmailMultiAlternatives
                msg = EmailMultiAlternatives(subject, content, from_address, to_address)
                msg.send()
예제 #41
0
def send_announcement(announcement, courseevent, module):
    """
    Send an announcement: it is send to the teachers and the particpants.
    Mentoki is set on CC. Sending uses django-mailqueue, so that send out
    emails are als stored in the database.
    """
    participants_emails = \
        list(CourseEventParticipation.objects.learners_emails(courseevent=courseevent))
    teachers_emails = \
        list(CourseOwner.objects.teachers_emails(course=courseevent.course))
    all_emails = participants_emails + teachers_emails
    send_all = ", ".join(all_emails)

    context = {
        'site': Site.objects.get_current(),
        'courseevent': courseevent,
        'announcement': announcement,
        'owners': courseevent.teachers,
        'betreff': "Neue Nachricht von Mentoki %s" % courseevent.title
    }
    message = get_template('email/announcement/announcement.html').render(
        Context(context))

    mail_message = MailerMessage()

    mail_message.subject = "Neue Nachricht von %s" % courseevent.title
    mail_message.bcc_address = settings.MENTOKI_COURSE_EMAIL
    mail_message.to_address = send_all
    mail_message.from_address = settings.MENTOKI_COURSE_EMAIL
    mail_message.content = "Neue Nachricht von %s and die Teilnehmer" % courseevent.title
    mail_message.html_content = message
    mail_message.reply_to = send_all
    mail_message.app = module

    mail_distributer = send_all
    logger.info("[%s] [Ankündigung %s %s]: als email verschickt an %s" %
                (courseevent, announcement.id, announcement, mail_distributer))
    mail_message.save()
    return mail_distributer
예제 #42
0
    def send_email_self(self):
        """
        email is send to mentoki
        """
        context = {
            'name': self.cleaned_data['name'],
            'email': self.cleaned_data['email'],
            'message': self.cleaned_data['message'],
            'betreff': "Nachricht an mentoki",
        }
        message = get_template('email/contact/to_mentoki.html').render(
            Context(context))

        to_mentoki = MailerMessage()
        to_mentoki.subject = "Kontaktanfrage an mentoki"
        to_mentoki.to_address = ContactForm.CONTACT_EMAIL
        to_mentoki.from_address = self.cleaned_data['email']
        to_mentoki.content = ContactForm.INTERNAL
        to_mentoki.html_content = message
        to_mentoki.reply_to = self.cleaned_data['email']
        to_mentoki.app = self.__module__
        to_mentoki.save()
예제 #43
0
파일: views.py 프로젝트: rhoerbe/ewtishop2
def request_users_password_reset(request):
	sent_mail_message = None
	if request.POST:
		sent_mail_message = True
		email = request.POST['email']
		
		try:
			user = User.objects.get(email=email)
			
			password_reset_token_cleartext = user.email + user.password + str(user.id)
			password_reset_token = hashlib.sha1(password_reset_token_cleartext).hexdigest()

			context = {'key': password_reset_token,
					'id': user.id,
					'hostname': request.scheme + "://" + request.get_host(),
			}
		
			subject = render_to_string('ewtiusersite/email_request_password_reset/subject.txt', context)
			msg_text = render_to_string('ewtiusersite/email_request_password_reset/text.txt', context)
		
			new_message = MailerMessage()
			new_message.subject = subject
			new_message.to_address = user.email
			new_message.from_address = settings.EMAIL_SENDER_ADDRESS
			new_message.content = msg_text
			new_message.app = "EWTI Password Reset"
			new_message.save()

			
		except ObjectDoesNotExist:
			pass

	return render_to_response('ewtiusersite/request_users_password_reset.html',
			{'sent_mail_message': sent_mail_message,
			 'hostname': request.scheme + "://" + request.get_host(),
			 },
			context_instance=RequestContext(request))
예제 #44
0
    def handle(self, *args, **options):
        # get all fresh funded exhibits
        exhibits = Exhibit.objects.full_fund_pause().filter(
            funded_unixtime__gte=time() - 5 * 60)
        users = Profile.objects.all()
        for exhibit in exhibits:
            # send email
            message = 'Item "%s" was fully funded. Bidding will be opened in few minutes. ' \
                      'Join the bidding at http://www.exhibia.com' % exhibit.item.name

            params = {
                'access_token': settings.FACEBOOK_APP_TOKEN,
                'template': message,
                'href': '#'
            }

            for user in users:

                if user.email:
                    email = MailerMessage()
                    email.subject = 'Bidding Alert'
                    email.from_address = settings.DEFAULT_FROM_EMAIL
                    email.html_content = message
                    email.to_address = user.email
                    try:
                        email.save()
                    except Exception as e:
                        self.stdout.write('Can\'t send email to %s %s' %
                                          (email.to_address, e))

                # check if user have fb accociation
                if user.is_facebook_verified():
                    try:
                        req = urllib2.Request(
                            "https://graph.facebook.com/%s/notifications" %
                            user.social_auth.filter(
                                provider='facebook')[0].uid,
                            urllib.urlencode(params), {})
                        urllib2.urlopen(req).read()
                    except (urllib2.HTTPError, KeyError) as error_message:
                        self.stdout.write(
                            'FAcebook error while sending message to user %s %s'
                            % (user.username, error_message))

                if user.phone:
                    sms = SmsMessage()
                    client = TwilioRestClient(settings.ACCOUNT_SID,
                                              settings.AUTH_TOKEN)
                    try:
                        client.sms.messages.create(body=message,
                                                   to=user.phone,
                                                   from_=settings.FROM_NUMBER)
                    except twilio.TwilioRestException as error_message:
                        sms.status = 'error'
                        sms.error_message = str(error_message)[:500]
                        self.stdout.write(
                            'TwilioRestExceptionr for user %s %s' %
                            (user.username, error_message))
                    else:
                        sms.status = 'success'

                    sms.save()
예제 #45
0
def verify(request, verification_type):

    verification_profile = VerificationProfile.objects.create_profile(
        request.user, verification_type=verification_type)
    initial = dict()

    if verification_profile.is_email():

        if request.user.is_email_verified:
            return render(request, 'account/modal_already_verified.html',
                          {'verification_type': verification_type})

        form_class = EmailVerificationForm
        form_action = reverse('verify-email')

        if request.user.email:
            initial['email'] = request.user.email

    else:

        if request.user.is_phone_verified:
            return render(request, 'account/modal_already_verified.html',
                          {'verification_type': verification_type})

        form_class = PhoneVerificationForm
        form_action = reverse('verify-phone')

        if request.user.phone:
            initial['phone'] = request.user.phone

    if request.method == "POST":
        form = form_class(data=request.POST, instance=verification_profile)
        if form.is_valid():
            # if there were old verification entry replace its verification code and other params with the new ones
            try:
                verification_profile = VerificationProfile.objects.get(
                    user=request.user, type=verification_type)
                verification_profile.email = form.instance.email
                verification_profile.phone = form.instance.phone
                verification_profile.verification_key = form.instance.verification_key
                verification_profile.attempts += 1
                verification_profile.save()

            except VerificationProfile.DoesNotExist:
                verification_profile = form.save()

            # don't send message if user send too many attemps
            if verification_profile.attempts > 6:
                msg = "You have exceeded your attemps. Please contact administrator"
                response = dict(phone=msg, email=msg)
                return HttpResponse(
                    json.dumps({
                        'response': response,
                        'result': 'error'
                    }))

            # send email verification
            if verification_profile.is_email():
                subject = 'Verification email from %s' % settings.SITE
                link = reverse('verify-check-key',
                               kwargs={
                                   'verification_key':
                                   verification_profile.verification_key
                               })
                html_message = render_to_string(
                    'account/verification_email.txt', {
                        'link': link,
                        'site': settings.SITE
                    })
                new_message = MailerMessage()
                new_message.subject = subject
                new_message.to_address = verification_profile.email
                new_message.from_address = settings.DEFAULT_FROM_EMAIL
                new_message.html_content = html_message
                new_message.save()

            # send phone verification
            else:
                client = TwilioRestClient(settings.ACCOUNT_SID,
                                          settings.AUTH_TOKEN)
                sms = SmsMessage(verification=verification_profile)

                try:
                    client.sms.messages.create(
                        body='Verification code is %s' %
                        verification_profile.verification_key,
                        to=verification_profile.phone,
                        from_=settings.FROM_NUMBER)
                except twilio.TwilioRestException as error_message:
                    response = dict(
                        phone="Can't send message. Please contact administrator"
                    )
                    sms.status = 'error'
                    sms.error_message = str(error_message)[:500]
                    sms.save()
                    return HttpResponse(
                        json.dumps({
                            'response': response,
                            'result': 'error'
                        }))
                else:
                    sms.status = 'success'
                    sms.save()

            callback_js = "$('#ModalVerify').modal('hide');"
            return HttpResponse(
                json.dumps({
                    'result': 'success',
                    'callback_js': callback_js
                }))

        else:
            response = {}
            for k in form.errors:
                response[k] = form.errors[k][0]

            return HttpResponse(
                json.dumps({
                    'response': response,
                    'result': 'error'
                }))
    else:
        form = form_class(initial=initial)

    return render(
        request, 'account/modal_verify.html', {
            'form': form,
            'verification_type': verification_type,
            'form_action': form_action
        })
예제 #46
0
import sys, os

sys.path.append(os.path.join(os.path.dirname(__file__) + '../', 'web'))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "web.settings")
from django.conf import settings
from mailqueue.models import MailerMessage

new_message = MailerMessage()
new_message.subject = "My Subject"
new_message.to_address = "*****@*****.**"
new_message.bcc_address = ""
new_message.from_address = "*****@*****.**"
new_message.content = "Mail content"
new_message.html_content = "<h1>Mail Content</h1>"
new_message.app = "Name of your App that is sending the email."
new_message.save()