def pending_email(sender, contact=None, event=None, **kwargs): assert event assert contact from django.core.mail import EmailMultiAlternatives price = event.get_price(contact) if event.pending_message: custom_text = pretty_print(event.pending_message) mail = EmailMultiAlternatives("Registration pending for %s" %(event, ), render_to_string("registration_pending.txt", locals()), FROM_EMAIL, ['"%s %s" <%s>' % (contact.first_name, contact.last_name, contact.email)] ) mail.attach_alternative(render_to_string("registration_pending_email.html", locals()), "text/html") mail.send() email_log.info("Sent Email To:%s - From:%s - Subject:%s" % (contact.email, FROM_EMAIL, "Registration pending for %s" %(event, )))
connection = CustomSMTPConnection(return_path = e.user.email) for c in e.recipients.all()[253:]: print "Sending to %s" % (c,) if c.do_not_email: continue if not c.email or c.email == '': continue message = e.message + u"<br><br><span style='font-size: 10px;'>You received this email because of your previous relationship with the IIT Institute of Design. To unsubscribe, <a href='http://%s/emails/unsubscribe/[id]/'>click here</a>." % settings.DOMAIN message = re.sub(u'\[first[_ ]name\]',c.first_name,message) message = re.sub(u'\[last[_ ]name\]',c.last_name,message) message = re.sub(u'\[id\]',"%d" % c.id,message) html_message = force_unicode(pretty_print(message)) if e.event: message = re.sub(u'\[register[_ ]link\]',u'http://'+settings.DOMAIN+reverse('event-register-token', kwargs={'slug':e.event.slug, 'token':c.get_token()}),message) if e.event: html_message = re.sub(u'\[register[_ ]link\]',u'<a href="http://'+settings.DOMAIN+reverse('event-register', kwargs={'slug':e.event.slug})+'">register</a>',html_message) mail = EmailMultiAlternatives(e.subject, force_unicode(pretty_print(message)), get_from(e), ['"%s %s" <%s>' % (c.first_name, c.last_name, c.email)], connection = connection) #mail = EmailMultiAlternatives(e.subject, pretty_print(message), from_email, ['*****@*****.**']) mail.attach_alternative(force_unicode(message), "text/html") if e.attachment: print "attached" mail.attach_file(e.attachment.path)