Mail control panel
==================

First some initial setup code:

    >>> from Products.CMFCore.utils import getToolByName
    >>> from zope.component import getUtility
    >>> from Products.MailHost.interfaces import IMailHost
    >>> ctool = getToolByName(self.portal, 'portal_calendar')
    >>> mailhost = getUtility(IMailHost)
    >>> self.loginAsManager()

Viewing the mail control panel
--------------------------------

    >>> self.browser.open('http://nohost/plone/@@mail-controlpanel')
    >>> self.browser.url.endswith('mail-controlpanel')
    True

Click the cancel button:

    >>> self.browser.getControl(name="form.actions.cancel").click()
    >>> self.browser.url.endswith('plone_control_panel')
    True

There should be still no changes:

    >>> 'Changes canceled.' in self.browser.contents
    True

Make some changes
-----------------

    >>> self.browser.open('http://nohost/plone/@@mail-controlpanel')
    >>> self.browser.url.endswith('mail-controlpanel')
    True

    >>> self.browser.getControl(name='form.smtp_host').value = 'localhost2'
    >>> self.browser.getControl(name='form.smtp_port').value = '2525'
    >>> self.browser.getControl(name='form.smtp_userid').value = 'admin'
    >>> self.browser.getControl(name='form.smtp_pass').value = 'secret'
    >>> self.browser.getControl(name='form.email_from_name').value = 'Spambot'
    >>> self.browser.getControl(name='form.email_from_address').value = 'spam@localhost'

Click the save button:

    >>> self.browser.getControl(name="form.actions.save").click()
    >>> self.browser.url.endswith('mail-controlpanel')
    True

We should be informed that something has changed:

    >>> 'Changes saved.' in self.browser.contents
    True

Make sure the changes have been applied correctly to the mailhost:

    >>> mailhost.smtp_host
    u'localhost2'

    >>> mailhost.smtp_port
    2525

    >>> getattr(mailhost, 'smtp_userid', mailhost.smtp_uid)
    u'admin'

    >>> getattr(mailhost, 'smtp_pass', mailhost.smtp_pwd)
    u'secret'

    >>> self.site_props.email_from_name
    u'Spambot'

    >>> self.site_props.email_from_address
    'spam@localhost'
