[Solved] Can't pickle objects in acquisition wrappers with collective.MockMailHost

Hi guys

I am creating an override for ”ContactForm” component of Volto, so when I try to test the email sending without any SMTP settings, I am enabling the ”collective.MockMailHost” addon to simulate the email sending, so I have an error message:

2025-11-09 17:14:41,988 INFO    [Products.CMFPlone.resources.browser.resource:351][waitress-2] Updated resource registry mtime.
2025-11-09 17:14:41,995 WARNING [Plone:315][waitress-2] Profile collective.MockMailHost:default has no metadata.xml version. Falling back to package version 3.0.0
2025-11-09 17:14:42,946 ERROR   [Zope.SiteErrorLog:35][waitress-2] TypeError: http://localhost:8080/Plone/install_products
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 187, in transaction_pubevents
  Module transaction._manager, line 255, in commit
  Module transaction._manager, line 132, in commit
  Module transaction._transaction, line 282, in commit
  Module transaction._transaction, line 273, in commit
  Module transaction._transaction, line 456, in _commitResources
  Module transaction._transaction, line 430, in _commitResources
  Module ZODB.Connection, line 494, in commit
  Module ZODB.Connection, line 541, in _commit
  Module ZODB.Connection, line 572, in _store_objects
  Module ZODB.serialize, line 433, in serialize
TypeError: Can't pickle objects in acquisition wrappers.

In both Zope's development and production modes, I get the above message.

I get the impression that this add-on is not updated for the following versions:

  • Plone 6.1.2 (6109)
  • CMF 3.7
  • Zope 5.13
  • Python 3.12.11 (main, Jun 18 2025, 19:09:13) [GCC 12.2.0]
  • PIL 11.2.1 (Pillow)
  • WSGI: Activar
  • Servidor: waitress 3.0.2

Any alternative to enable the test the email sending?

See the readme: “THIS IS FOR TESTING PURPOSE ONLY, do not use this product on your running Plone site.” It’s meant to be added in test setup only, not installed as an add-on.

To confirm email is sent without actually sending it, I suggest Products.PrintingMailHost.

To actually send it, but to a fake mail server with an inbox that you can view in a browser, run mailhog ( GitHub - mailhog/MailHog: Web and API based SMTP testing ) and configure Plone to use it as the SMTP server.

1 Like

@davisagli The Products.PrintingMailHost add-on worked for me. Thank you very much.

FTR, I have a setup that I find really convenient that uses MailDev.

I start MailDev with

npm exec maildev --smtp 8025 --web 8026

In my dev instance, I use collective.regenv:

[instance]
eggs +=
    collective.regenv

environment-vars +=
    PLONE_REGISTRY_YAML ${buildout:directory}/etc/registry.yaml

The registry.yaml file looks like:

---
/Plone/portal_registry:
  plone.smtp_host: "localhost"
  plone.smtp_port: 8025
  ...

Whenever I want to check the emails sent, I just go to the web interface (i.e. http://localhost:8026).

P.s.: you can even not use collective.regenv and configure the settings in the mail control panel, but it is super handy for multiple reasons, e.g. to avoid sending unwanted emails when you copy the Data.fs from production to staging or your developer environment.

4 Likes