Turbomail Integration with Pyramid
Question: I am in need of a method to send an email from a Pyramid application. I know
of
[pyramid_mailer](http://docs.pylonsproject.org/projects/pyramid_mailer/en/latest/),
but it seems to have a fairly limited message class. I don't understand if
it's possible to write the messages from pyramid_mailer using templates to
generate the body of the email. Further, I haven't seen anything regarding
whether rich-text is supported, or if it's just simple plain-text.

Previously, I was using [Turbomail](http://pypi.python.org/pypi/TurboMail)
with the Pylons framework. Unfortunately there doesn't appear to be any
adapters available for TurboMail for Pyramid. I know that TurboMail can be
extended for additional frameworks, but have no idea where I would even start
such a task. Has anyone written an adapter for Pyramid or can point me in the
right direction of what would be required to do so?


Answer: I can't answer your Turbomail questions other than to say that I've heard it
works fine with Pyramid.

Regarding pyramid_mailer, it's entirely possible to render your emails using
the same subsystem that lets pyramid render all of your templates.

    
    
    from pyramid.renderers import render
    
    opts = {} # a dictionary of globals to send to your template
    body = render('email.mako', opts, request)
    

Also, the pyramid_mailer Message object is based on the lamson MailResponse
object, which is stable and well-tested.

You can create a mail that consists of both a plain text body as well as html,
by specifying either the `body` or `html` constructor parameters to the
Message class.

    
    
    plain_body = render('plain_email.mako', opts, request)
    html_body = render('html_email.mako', opts, request)
    msg = Message(body=plain_body, html=html_body)
    

