2

Are there examples of sending simple HTML formatted emails (<h1>, <b> and such) out from Plone?

Plain text is well-covered, but there are no HTML email out examples.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435

2 Answers2

3

You can adapt any of the many python email module examples. Because HTML email usually means sending multipart/alternative messages, things get a little more complicated.

You basically have to construct an email.Message object and pass that to Mailhost.send.

Community
  • 1
  • 1
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
1

Depending on your use case, you could also use collective.watcherlist. This was factored out of Products.Poi, which uses it to allow users to subscribe to updates for an issue. That part may not be interesting for you, but it has code that takes a browserview as basis for sending an email. Hooking a page template up to that browserview is of course simple.

If you cannot use it directly, it may serve as a code example.

maurits
  • 2,355
  • 13
  • 16