Composer
========

    >>> from ftw.notification.email.composer import HTMLComposer
    >>> from ftw.notification.email.composer import create_html_mail
    >>> from ftw.notification.email.interfaces import IEMailRepresentation, ISubjectCreator
    >>> from zope.app.component.hooks import getSite
    >>> from Products.CMFCore.utils import getToolByName
    >>> from plone.app.testing import TEST_USER_NAME
    >>> from plone.app.testing import TEST_USER_ID
    >>> from plone.app.testing import setRoles
    >>> from plone.app.testing import login



Globals:
    >>> app = layer.get('app')
    >>> portal = layer.get('portal')
    >>> request = layer.get('request')

create the message object:

    >>> login(portal, TEST_USER_NAME)
    >>> setRoles(portal, TEST_USER_ID, ['Member', 'Contributor', 'Manager'])
    >>> portal.invokeFactory('File', 'testdoc')
    'testdoc'
    >>> obj = portal['testdoc']
    >>> subject = ISubjectCreator(obj)(obj)

    >>> email = IEMailRepresentation(obj)('Subject',
    ...                                   [(u'H\xfcgo B\xf6ss','h.boss@testing.ch')],
    ...                                   [('Testi Testmann','testi@testing.ch')],
    ...                                   'Message Body', **{'sender':('test','test@localhost')})
    >>> email
    <email.mime.multipart.MIMEMultipart instance ...>
    >>> content=email.get_payload()[0]
    >>> conseption=content.get_payload()
    >>> print conseption[0].get_payload()
    <BLANKLINE>
    test has sent you a notification comment
    <BLANKLINE>
    Message Body
    <BLANKLINE>
    ------------------------------------------------------------------------
    <BLANKLINE>
    http://nohost/plone/testdoc[1]
    <BLANKLINE>
    ------------------------------------------------------------------------
    <BLANKLINE>
    This mail was generated automatically. For answering to the sender,
    please see the contact details in the footnote.
    <BLANKLINE>
    --
    <BLANKLINE>
    test - test@localhost
    <BLANKLINE>
    ------------------------------------------------------------------------
    <BLANKLINE>
    [1] http://nohost/plone/testdoc
    <BLANKLINE>

    >>> print conseption[1].get_payload()
    <html xmlns=3D"http://www.w3.org/1999/xhtml" xml:lang=3D"en" lang=3D"en">
    <head>
    <title>Subject</title>
    <BLANKLINE>
    </head>
    <body style=3D"font-family: Arial !important; font-size: 10pt !important">
    <div id=3D"message" style=3D"width: auto">
    <p style=3D"width: auto">test has sent you a notification</p>
    <strong>comment</strong><br />
    <p style=3D"width: auto">Message Body</p>
    <hr style=3D"border: none; border-bottom: 1px solid grey" />
    <h2 style=3D"border: none; font-family: Arial !important"></h2>
    <p style=3D"width: auto"></p>
    <p style=3D"width: auto"><a href=3D"http://nohost/plone/testdoc" style=3D"c=
    olor: Black !important; padding: 0 !important; text-decoration: underline !=
    important">http://nohost/plone/testdoc</a></p>
    <hr style=3D"border: none; border-bottom: 1px solid grey" />
    <p style=3D"width: auto">
        This mail was generated automatically. For answering to the sender,
        please see the contact details in the footnote.
    </p>
    <p style=3D"width: auto">--</p>
    <p style=3D"width: auto">test - test@localhost</p>
    </div>
    </body>
    </html>

    >>> email.items()
    [('Content-Type', 'multipart/mixed'), ('MIME-Version', '1.0'), ('Subject', <email.header.Header instance at ...>), ('From', ''), ('To', '=?utf-8?q?H=C3=BCgo_B=C3=B6ss?= <h.boss@testing.ch>'), ('Date', '...'), ('Message-ID', '<...>'), ('CC', 'Testi Testmann <testi@testing.ch>'), ('Reply-To', 'test <test@localhost>')]
    >>> mailhost = getToolByName(obj, "MailHost")
    >>> mailhost
    <MailHost at /plone/MailHost>
    >>> mailhost.smtp_host
    ''
    >>> mailhost.send(email.as_string(), 'v.baumann@4teamwork.ch', 'test@localhost', 'Subject')
