Skip to content

Instantly share code, notes, and snippets.

@jcarbaugh
Created March 24, 2011 20:55
Show Gist options
  • Save jcarbaugh/885854 to your computer and use it in GitHub Desktop.
Save jcarbaugh/885854 to your computer and use it in GitHub Desktop.
create_post method for posting by email with django-cloudmailin
def create_post(**message):
author = User.objects.get(email=message['from'])
title = message['subject']
content = message['plain']
p = Post.objects.create(
author=author,
title=title,
content=content,
)
send_mail(
subject='New blog post created',
message='http://example.com/admin/blog/post/%i/\n\n%s' % (p.pk, text),
from_email='[email protected]',
recipient_list=[message['from']],
fail_silently=True
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment