I am in need of a method to send an email from a Pyramid application. I know of pyramid_mailer, 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 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?
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.
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
orhtml
constructor parameters to the Message class.you install turbomail
create a file in your pyramid project (i put my in lib) with something like this:
and then in your controller you just call this function like this: