def send_emails(self): self.subject = 'You Have Earned A Gift' for entity in self.email_list: t = get_template('gifts_notification_email.html') c = Context(dict(org_name=self.profile.business_name, name='%s %s' % (entity.first_name, entity.last_name))) body = t.render(c) send_email(subject=self.subject, body=body, to_email=[entity.email,])
def check_organization_referral_upgrade(): profiles = models.EntityProfile.objects.filter(entity_type='org', entity_active=True) for profile in profiles: if not profile.plan.unlimited_referrals: if profile.referrals_made > (profile.plan.max_referrals_allowed - settings.REFERRALS_UPGRADE): subject = 'Upgrading your Nationwide Finance Plan' t = get_template('organization_plan_upgrade.html') c = Context(dict(referrals_made=profile.referrals_made, business_name=profile.business_name, max_referrals=profile.plan.max_referrals_allowed)) body = t.render(c) send_email(subject=subject, body=body, to_email=[profile.entity_contact.email,])
def contact_us(request): if request.method == "POST": from nationwidefinance.mailer import send_email fullname = request.POST.get("fullname") message = request.POST.get("message") email = request.POST.get("email") if not fullname or not message or not email: return render_to_response( "message.html", dict(title="Invalid Message", message="Please Complete All Form Field"), context_instance=RequestContext(request), ) subject = "You have been sent a message by %s" % fullname body = "Message From %s<br/><br/>%s" % (email, message) send_email(subject=subject, body=body, to_email=[settings.ADMINS[0][1]], fail_silently=True) return render_to_response( "message.html", dict(title="Message Sent", message="Message Sent"), context_instance=RequestContext(request) ) raise RuntimeError("can't access")