def send_contact_email(toEmail, fromEmail, subject, message): send_mail(subject, message, fromEmail, toEmail, fail_silently=False) email = Email(to_email=toEmail, from_email=fromEmail, subject=subject, message=message, email_type=CONTACT_EMAIL) email.save() return
def send_post_verification_email(url, userEmail, postType): sub = SUBJECT_MAPPINGS.get(postType) context = {"url": url, "object": POST_MAPPINGS.get(postType)} msg = render_to_string('mailer/postTemplate.txt', context) fromEmail = settings.FROM_EMAIL send_mail(sub, msg, fromEmail, [userEmail], fail_silently=False) email = Email(to_email=userEmail, from_email=fromEmail, subject=sub, message=msg, email_type=SIGNUP_VERIFY) email.save() return
def send_signup_verification_email(url, userEmail, firstname): sub = SUBJECT_MAPPINGS.get('signup') context = {"url": url, "firstname": firstname} msg = render_to_string('mailer/signupTemplate.txt', context) fromEmail = settings.FROM_EMAIL send_mail(sub, msg, fromEmail, [userEmail], fail_silently=False) email = Email(to_email=userEmail, from_email=fromEmail, subject=sub, message=msg, email_type=SIGNUP_VERIFY) email.save() return
def send_survey_email(url, userEmail): sub = SUBJECT_MAPPINGS.get('survey') context = {"url": url} msg = render_to_string('mailer/surveyTemplate.txt', context) fromEmail = settings.FROM_EMAIL send_mail(sub, msg, fromEmail, [userEmail], fail_silently=False) email = Email(to_email=userEmail, from_email=fromEmail, subject=sub, message=msg, email_type=SIGNUP_VERIFY) email.save() return
def initialize_mailing(template_email_id, organizationelection_id, priority): """Hey fa""" source_email = Email.objects.select_related('mailingtemplate').get( id=template_email_id) source_org_election = OrganizationElection.objects.select_related( 'organization', 'organization__from_address').get(pk=organizationelection_id) source_blocks = source_email.blocks.only('id') source_categories = source_email.categories.only('id') new_email = Email(organization=source_org_election.organization, subject=source_email.subject, pre_header=source_email.pre_header, from_name=source_email.from_name, body_above=source_email.body_above, body_below=source_email.body_below) new_email.save() new_email.blocks.set(source_blocks) new_email.categories.set(source_categories) new_mailing = Mailing( email=new_email, template=source_email.mailingtemplate, organization_election=source_org_election, from_email=source_org_election.organization.from_address.address, source=generate_source(new_email), status='pending') new_mailing.save() initialize_recipients.apply_async(kwargs={ 'email_id': new_email.id, 'organizationelection_id': source_org_election.id, 'priority': priority }, priority=priority) logger.info(u'Mailing Initalized. Email %s OElection %s Org %s', new_mailing.pk, source_org_election.id, source_org_election.organization_id) newrelic.agent.add_custom_parameter('email_id', new_email.pk) newrelic.agent.add_custom_parameter('organization_id', source_org_election.organization_id)
def send(self): msg = Email(subject=self.subject, body=self.text_content, html=self.html_content, user=self.user, recipient=self.to, from_address=self.from_address, headers = self.headers) msg.send(self.update_next_email_time)