Shu Zong Chen avatar Shu Zong Chen committed c79a3e4 Merge


Comments (0)

Files changed (4)


 from django.template import Template, Context
-from django.core.mail import send_mail, BadHeaderError
+from django.core.mail import EmailMessage, BadHeaderError
 def email_callback(**kwargs):
 	Creates a callback function that sends an email.
 	tmpls = dict((k, Template(v)) for k,v in kwargs.iteritems())
-	def cb(ctx):
+	def cb(request, ctx):
 		c = Context(ctx)
 			subject = tmpls['subject'].render(c)
 			message = tmpls['body'].render(c)
 			mail_to = tmpls['to'].render(c)
 			mail_from = tmpls['from'].render(c)
-			send_mail(subject, message, mail_from, [mail_to,], fail_silently=False)
+			headers = {}
+			if 'reply_to' in tmpls:
+				headers['Reply-To'] = tmpls['reply_to'].render(c)
+			email = EmailMessage(subject, message, mail_from, [mail_to,], headers=headers)
+			email.send(fail_silently=False)
 		except BadHeaderError:
 			#TODO: logging
 	Create a callback to encapsulate multiple other callbacks.
 	cbs = args
-	def cb(ctx):
+	def cb(request, ctx):
 		for _cb in cbs:
-			_cb(ctx)
+			_cb(request, ctx)
 	return cb


 		if cb is not None and self.request.method == 'POST':
 			if self.form.is_valid():
 				data = self.form.cleaned_data
-				cb(data)
+				cb(self.request, data)
 				self.success = True
 	def render_widget(self):
Add a comment to this file


File contents unchanged.

 	name = 'django-contact-forms',
-	version = '0.1',
+	version = '0.1.1',
 	#packages = ['contactforms',],
 	packages = find_packages(),
 	include_package_data = True,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.