Hi Iain, iain duncan schrieb: > I have some clients who are paying too much for bad mail management apps > from which they only use a fraction of the features. I'm wondering how > feasible it would be to just add html mailing features to their tg apps.
Sending email from TG apps should be definitely an option and TurboMail makes this very easy. > Some questions: > > - what should I use to build the html mails? the stdlib email module? Yes. Though you need to wade through a bit of documentation to understand the module it's definitely worth it and every Python programmer should know this module well IMHO. Start with the examples on the last page of the module docs. > - sending, turbomail? Definitely. It's easy to program a fall-back email sending function in case TurboMail isn't installed, but TM makes sending email non-blocking, because it runs in its own thread. > - generating the email, what would be the best way to take a genshi > template plus html content and get it rendered such that the css becomes > inline? is there something else out there that does that? I know of no pre-made solution, but using Genshi is surely an option. You have to keep in mind though, that it is good practice to include a plain text alternative of the HTML content and for plain text templates Genshi sucks a bit and something like Cheetah or Jinja might be a better option there. > Any tips or horror stories from anyone who's tried something similar > would be much appreciated! If you look at the example project attached to http://docs.turbogears.org/1.0/ErrorReporting in the 'errorhandling.ErrorCatcher' class, you can see how generating an email and sending it with TurboMail or the smtplib module works (see 'send_exception_email' method). Though this code only sends plain text emails, it uses templates to generate them (see '_render_error_template' method) and the code should work for Kid/Genshi templates equally well*. As for composing HTML mails and inlining CSS and images, I don't have code for this but there are recipes in the Python cookbook that can help with that: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/67083 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473810 Chris * But be aware that this code only works from within a TG request, since 'turbogears.controllers._process_output' needs access to 'cherrypy.request/response'. If that doesn't work for you, you need to handle the template rendering yourself, but then you can't take advantage of all the TG machinery like widget handling, default template vars, etc. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

