Skip to main content

Products.PrintingMailHost

This is a hack. :)

This product, when installed, will check if Zope is running in debug mode, and if so, monkey patch (that is, grab the internals of, squeeze tight, then rip hard, just like monkeys do) Zope's MailHost class, meaning that any and all uses of a MailHost will be "fixed" so that instead of sending mail, it prints messages to the zope event log.

This is useful if you don't have a local mailhost for testing, or if you prefer not to spam the crap out of yourself whilst finding out if your bulk mail script is working.

If Zope is not running in debug mode, it will not install itself. However, I wouldn't recommend putting it on a production site. You never know what those monkeys may get up to...

You can optionally enable the PrintingMailHost with an environment variable as of version 0.3. See the installation instructions for more information about how to use it.

Compatibility

Works on Plone 6.2 (in Python 3.10-3.14).

Author

Martin Aspeli <optilude (AT) gmx (DOT) net> Initial idea, release management

Contributors

Dorneles Tremea <deo (AT) plonesolutions (DOT) com> Fixed to work both with old-style and new-style classes. Extended to also patch SecureMailBase from SecureMailHost, if available.

Clayton Parker <clayton (AT) sixfeetup (DOT) com>

Maurits van Rees <maurits (AT) vanrees (DOT) org>

Harald Friessnegger <harald (AT) webmeisterei (DOT) com>

Installation

To include Products.PrintingMailHost in your pip installation of Plone, just add it to requirements.txt.

To install Products.PrintingMailHost into your Plone instance in buildout, you can do this:

  • Add Products.PrintingMailHost to the list of eggs to install, e.g.:
[instance]
...
eggs =
    ...
    Products.PrintingMailHost
  • If you want to enable PrintingMailHost when debug-mode is off:
[instance]
...
environment-vars =
    ...
    ENABLE_PRINTING_MAILHOST True
  • If you want to disable PrintingMailHost when debug-mode is on:
[instance]
...
environment-vars =
    ...
    ENABLE_PRINTING_MAILHOST False
  • If PrintingMailHost is enabled, and you additionally want to send each email to a fixed address, you can add another environment variable:
[instance]
...
environment-vars =
    ...
    PRINTING_MAILHOST_FIXED_ADDRESS admin@example.org

Or multiple addresses separated by spaces:

    PRINTING_MAILHOST_FIXED_ADDRESS one@example.org two@example.org

For clarity: this first prints the email, with the original recipient address, and then sends an actual email with the same contents to the fixed address you have specified. The original recipient is visible in the To: field. It is similar to receiving a blind carbon copy (bcc) of an email, except that the original recipient never gets the email.

  • Re-run buildout in order to make any of the above changes active:
./bin/buildout

Changelog

2.1.0 (2026-03-27)

New features

  • Add functions apply_patches and undo_patches. apply_patches is called at Zope startup. @mauritsvanrees

Bug fixes

  • Sending to a fixed address will happen immediately, if asked. @mauritsvanrees

Tests

  • Add tests. Use the new apply_patches and undo_patches to help in these tests, without the patches bleeding over into other tests. @mauritsvanrees

2.0.1 (2025-12-23)

Bug fixes:

  • Fix import of base64.decodebytes. [maurits]

2.0.0 (2025-12-23)

Breaking changes:

  • Replace pkg_resources namespace with PEP 420 native namespace. Support only Plone 6.2 and Python 3.10+. #3928

Internal:

  • Update configuration files @plone

1.1.8 (2025-06-19)

  • Update readme with compatibility information. @ksuess

1.1.7 (2023-02-23)

  • Fixed URL in startup message. @gforcada

1.1.6 (2021-05-06)

  • Fix Python 3.9 compatibility. @thet

1.1.5 (2020-11-02)

  • Fix support for MailHost 4.10 (see issue 33). @pbauer

1.1.4 (2020-06-10)

  • Fixed SyntaxError in previous release. @tareqalam

1.1.3 (2020-06-10)

  • Encoding fix for Python 3 @ajung

1.1.2 (2019-03-05)

  • Restore compatibility with plone.api. @pbauer

1.1.1 (2019-02-28)

  • Add support Python 3 @pbauer

1.1.0 (2018-06-08)

  • Check environment variables in Zope2 initialize instead of import time. This allows to configure environment-vars in zope.conf and use them when starting the instance with slc.zopescript @fRiSi

1.0 (2016-09-20)

  • Treat FIXED_ADDRESS as a list. Previously, depending on your Plone version. a fixed address could get interpreted as a list of single-character email addresses, which of course does not work. Now it works properly. You can also give a list of addresses by separating them using spaces: one@example.org two@example.org. Fixes https://github.com/collective/Products.PrintingMailHost/issues/4 @maurits

0.8 (2015-04-16)

  • Add environment variable PRINTING_MAILHOST_FIXED_ADDRESS to send all emails to a single, fixed address. PrintingMailHost still needs to be enabled, so this is in addition to printing. https://github.com/collective/Products.PrintingMailHost/issues/2 @maurits

  • Since we can enable PMH via an environment variable and thus when not running in debug mode / foreground, emails are no longer printed, but written to the zope event log. @pysailor

0.7 (2010-01-05)

  • Also patch (Secure)MaildropHost when available. @maurits

0.6 (2010-01-05)

  • Allow passing keyword 'immediate'. Needed for Plone 4 compatibility. @maurits

0.5 (2009-08-07)

  • Fix email Message import @claytron

0.4 (2009-07-24)

  • Rough support for multipart email messages @iElectric

0.3 (2009-03-22)

  • Decode base64 encoded email messages @claytron

  • Added environment variable (ENABLE_PRINTING_MAILHOST) to enable or disable PrintingMailHost @claytron

  • Update README and HISTORY.txt @claytron

0.2 (2008-08-20)

  • Release as an egg to PyPi @claytron

0.1

  • Updated to use the new standard log mechanism: logging.getLogger. Reformatted messages/docstrings. @dtremea (2006-03-17)

  • Extended to also patch SecureMailBase from SecureMailHost, if available. @dtremea (2005-10-23)

  • Fixed to work both with old-style and new-style classes, as in the later, dict is a 'dictproxy' instance, which doesn't have the setitem method. Bumpped version. Noted changes. And clean up whitespaces, of course... ;-) @dtremea (2005-10-23)

  • Initial creation/release @optilude (2005-04-05)

Release files for Products.PrintingMailHost 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Products.PrintingMailHost 2.1.0
File Size Uploaded
products_printingmailhost-2.1.0.tar.gz 18.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Products.PrintingMailHost 2.1.0
File Interpreter ABI Platform
products_printingmailhost-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.2 kB

Release files / products_printingmailhost-2.1.0.tar.gz

Download URL products_printingmailhost-2.1.0.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2dab0b803723b1fa4cc2d4ac959945f1970df74beefd97349bb3b9ecf8295777
BLAKE2b-256 checksum
How to use checksums
bddaf2d63f4935de92fc5fc094514a1e70798e9d1b1f831acbac26b1966ab6d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / products_printingmailhost-2.1.0-py3-none-any.whl

Download URL products_printingmailhost-2.1.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63b5aa3a5d756fa5a2bfed7d52c44397fac278ecb3bccc1cc1cb4ef7a39e8eda
BLAKE2b-256 checksum
How to use checksums
be0719783be16de6aa85469190e8ff2ee568126430d0817ac3b53f1cc67c3af6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.8

2 release files

1.1.7

1 release file

1.1.6

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page