Skip to content

Instantly share code, notes, and snippets.

@amcgregor
Created July 3, 2011 16:36
Show Gist options
  • Save amcgregor/1062364 to your computer and use it in GitHub Desktop.
Save amcgregor/1062364 to your computer and use it in GitHub Desktop.
Utilizing marrow.mailer in your Pyramid application.
"""Marrow Mailer integration sample for Pyramid.
For information on Mailer, see:
https://github.com/marrow/marrow.mailer#readme
Delivery methods include: Google AppEngine, IMAP, log, maildir, mbox, sendmail,
Amazon Simple E-Mail Service, and SMTP.
"""
from pyramid.config import Configurator
from myproject.resources import Root
from marrow.mailer import Delivery
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application."""
config = Configurator(root_factory=Root, settings=settings)
# ...
config.registry['mailer'] = Delivery(config, 'mail')
return config.make_wsgi_app()
# In a view, later:
from marrow.mailer import Message
def my_view(request):
message = Message(...)
receipt = request.registry['mailer'].send(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment