Skip to content

When email sending fails, new user is still half created #149

@mauritsvanrees

Description

@mauritsvanrees

Describe the bug

When registering a new user fails, this can still leave behind a remnant of a user.

To Reproduce

Steps to reproduce the behavior:

  1. In email settings panel, use for example localhost port 1025. Make sure no mail host is actually listening there, and nothing like PrintingMailHost is active. We want email sending to fail.
  2. Go to users control panel and click to add a new user.
  3. Fill in the form correctly, and make sure 'Send a confirmation mail' is checked.
  4. Click the Register button.
  5. You get an error in the form: "Failed to create your account: we were unable to send instructions for setting a password to your email address"
  6. Do not continue with registration, but go back to the Users control panel and reload the page.
  7. You see two lines in the event log like this:
2026-03-18 22:45:35,028 WARNING [Products.CMFPlone:78][waitress-2] Skipped user without principal object: hoppa
2026-03-18 22:45:35,029 WARNING [Products.CMFPlone:108][waitress-2] Skipped user without principal object: hoppa

Expected behavior

User is totally not created.

At first I tried this with email address as login name and UUID user ids. But later I tried it with the default security settings, and this has the same problem.

The failed sending of an email shows up in the logs with this traceback:

Connection refused
Traceback (most recent call last):
  File "/Users/maurits/community/plone-coredev/6.2/src/plone.app.users/src/plone/app/users/browser/register.py", line 457, in handle_join_success
    response = registration.registeredNotify(user_id)
  File "/Users/maurits/community/plone-coredev/6.2/src/Products.CMFPlone/src/Products/CMFPlone/RegistrationTool.py", line 467, in registeredNotify
    host.send(
    ~~~~~~~~~^
        mail_text,
        ^^^^^^^^^^
    ...<5 lines>...
        immediate=True,
        ^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/maurits/shared-eggs/v5/cp314/Products.MailHost-6.1-py3.14-macosx-26.2-arm64.egg/Products/MailHost/MailHost.py", line 222, in send
    self._send(mfrom, mto, msg, immediate)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maurits/shared-eggs/v5/cp314/Products.MailHost-6.1-py3.14-macosx-26.2-arm64.egg/Products/MailHost/MailHost.py", line 328, in _send
    self._makeMailer().send(mfrom, mto, messageText)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maurits/shared-eggs/v5/cp314/zope.sendmail-7.0-py3.14-macosx-26.2-arm64.egg/zope/sendmail/mailer.py", line 94, in send
    self.vote(fromaddr, toaddrs, message)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maurits/shared-eggs/v5/cp314/zope.sendmail-7.0-py3.14-macosx-26.2-arm64.egg/zope/sendmail/mailer.py", line 67, in vote
    self.connection = self.smtp(self.hostname, str(self.port))
                      ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maurits/.pyenv/versions/3.14.2/lib/python3.14/smtplib.py", line 262, in __init__
    (code, msg) = self.connect(host, port)
                  ~~~~~~~~~~~~^^^^^^^^^^^^
  File "/Users/maurits/.pyenv/versions/3.14.2/lib/python3.14/smtplib.py", line 348, in connect
    self.sock = self._get_socket(host, port, self.timeout)
                ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maurits/.pyenv/versions/3.14.2/lib/python3.14/smtplib.py", line 319, in _get_socket
    return socket.create_connection((host, port), timeout,
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
                                    self.source_address)
                                    ^^^^^^^^^^^^^^^^^^^^
  File "/Users/maurits/.pyenv/versions/3.14.2/lib/python3.14/socket.py", line 870, in create_connection
    raise exceptions[0]
  File "/Users/maurits/.pyenv/versions/3.14.2/lib/python3.14/socket.py", line 855, in create_connection
    sock.connect(sa)
    ~~~~~~~~~~~~^^^^
ConnectionRefusedError: [Errno 61] Connection refused

Software (please complete the following information):

This is Plone coredev buildout 6.2. Classic UI.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions