ZC buildout recipe to setup zope.sendmail in a Zope2 instance
Project description
Code repository: http://svn.somewhere.com/…
Change history
0.1 (xxxx-xx-xx)
Created recipe with ZopeSkel [Ingeniweb].
Detailed Documentation
Supported options
The recipe supports the following options:
zope2location
A path to a Zope2 instance
name
The name of the mail queue delivery utility. Default to iw.mailer.
host
Your smtp host. Default to localhost.
port
Yout smtp port. Default to 25.
mailqueue
A path to an existing directory to create a mailqueue. Default to var/. Be aware that this need to be an absolute path.
Example usage
The PyPI page for zc.buildout contains documentation about the test environment.
Below is a skeleton doctest that you can start with when building your own tests.
We’ll start by creating a buildout that uses the recipe:
>>> write('buildout.cfg',
... """
... [buildout]
... parts = mailer
...
... [mailer]
... recipe = iw.recipe.sendmail
... zope2location=parts/zope2
... host = smtp.example.com
... """)
Simulate the Zope2 part:
>>> mkdir('parts','zope2')
>>> mkdir('parts','zope2','etc')
>>> mkdir('parts','zope2','etc','package-includes')
Running the buildout gives us:
>>> print system(buildout) Installing mailer. iw.sendmail.zcml: Generated file 'iw.sendmail.zcml'.
And see the results zcml stub:
>>> cat('parts','zope2','etc','package-includes', 'iw.sendmail.zcml')
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml"
xmlns:mail="http://namespaces.zope.org/mail">
<BLANKLINE>
<mail:smtpMailer
name="iw.smtp"
hostname="smtp.example.com"
port="25"
/>
<BLANKLINE>
<mail:queuedDelivery
name="iw.mailer"
permission="zope.Public"
mailer="iw.smtp"
queuePath="/sample-buildout/var/mailqueue"
/>
<BLANKLINE>
<configure zcml:condition="installed iw.mailhost">
<include package="iw.mailhost" />
</configure>
<BLANKLINE>
</configure>
Let’s try with all parameters:
>>> write('buildout.cfg',
... """
... [buildout]
... parts = mailer
...
... [mailer]
... recipe = iw.recipe.sendmail
... zope2location=parts/zope2
... name = mailer
... host = smtp.example2.com
... port = 50
... mailqueue = ${buildout:directory}
... """)
Running the buildout again:
>>> print system(buildout) Uninstalling mailer. Installing mailer. iw.sendmail.zcml: Generated file 'iw.sendmail.zcml'.
And see the results zcml stub:
>>> cat('parts','zope2','etc','package-includes', 'iw.sendmail.zcml')
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml"
xmlns:mail="http://namespaces.zope.org/mail">
<BLANKLINE>
<mail:smtpMailer
name="iw.smtp"
hostname="smtp.example2.com"
port="50"
/>
<BLANKLINE>
<mail:queuedDelivery
name="mailer"
permission="zope.Public"
mailer="iw.smtp"
queuePath="/sample-buildout/mailqueue"
/>
<BLANKLINE>
<configure zcml:condition="installed iw.mailhost">
<include package="iw.mailhost" />
</configure>
<BLANKLINE>
</configure>
Contributors
Ingeniweb, Author