def send_mandrill_template_mail(template_name, template_content, args): """ Send Mandrill email template. """ message = MandrillTemplateMail(template_name, template_content, args) if settings.MANDRILL_API_KEY: message.send() else: log.warn('Missing MANDRILL_API_KEY: not sending Mandrill template message')
def sendAdminEmail(subject,user,profile,template,dtz=False,body=''): fmt = '%Y-%m-%d %H:%M:%S %Z' d = datetime.datetime.now(pytz.timezone("America/New_York")) dtz_string = d.strftime(fmt) + ' ' + "America/New_York" if dtz: subject = subject + ' at ' + dtz_string recips = [] map(lambda x: recips.append({'email':x}), settings.ADMINISTRATOR_EMAIL) template_content = [] message = { 'from_email': settings.DEFAULT_FROM_EMAIL, 'from_name': settings.DEFAULT_FROM_NAME, 'subject': subject, 'to': recips, 'global_merge_vars': [ {'name':'SUBJECT', 'content': subject}, {'name':'FIRST_NAME', 'content': profile.FirstName}, {'name':'LAST_NAME', 'content': profile.LastName}, {'name':'COMPANY', 'content': profile.Company}, {'name':'EMAIL', 'content': user.email}, {'name':'CURRENT_DATE', 'content': dtz_string}, {'name':'BODY', 'content': body} ], } mail = MandrillTemplateMail(template, template_content, message) result = mail.send()
def sendAnEmail(subject,to,template,vars): template_content = [] message = { 'from_email': settings.DEFAULT_FROM_EMAIL, 'from_name': settings.DEFAULT_FROM_NAME, 'subject': subject, 'to': [{'email': to,}], 'global_merge_vars': vars, } mail = MandrillTemplateMail(template, template_content, message) result = mail.send()