We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Bug: `_smtp` is missing at SMTPMailer's __init__ patching what is introduced in zope.sendmail from version  4.1.0
### What I did:
I am working on internal Addon development (adding support for Plone 5.2) , sending mail notification one of the part functionalities. FYI: some how I forget to active MockMailhost.
When I run all my existing unittests and  got unexpected errors : 

```
File "/home/nazrul/.cache/buildout/eggs/plone.testing-7.0.0-py2.7.egg/plone/testing/zope.py", line 859, in testTearDown
    transaction.abort()
  File "/home/nazrul/.cache/buildout/eggs/transaction-2.4.0-py2.7.egg/transaction/_manager.py", line 255, in abort
    return self.manager.abort()
  File "/home/nazrul/.cache/buildout/eggs/transaction-2.4.0-py2.7.egg/transaction/_manager.py", line 136, in abort
    return self.get().abort()
  File "/home/nazrul/.cache/buildout/eggs/transaction-2.4.0-py2.7.egg/transaction/_transaction.py", line 529, in abort
    reraise(t, v, tb)
  File "/home/nazrul/.cache/buildout/eggs/transaction-2.4.0-py2.7.egg/transaction/_transaction.py", line 515, in abort
    rm.abort(self)
  File "/home/nazrul/.cache/buildout/eggs/zope.sendmail-4.2-py2.7.egg/zope/sendmail/delivery.py", line 57, in abort
    self.onAbort()
  File "/home/nazrul/.cache/buildout/eggs/zope.sendmail-4.2-py2.7.egg/zope/sendmail/mailer.py", line 78, in abort
    if self.connection is None:
  File "/home/nazrul/.cache/buildout/eggs/zope.sendmail-4.2-py2.7.egg/zope/sendmail/mailer.py", line 48, in <lambda>
    return property(lambda self: getattr(self._smtp, name),
AttributeError: 'SMTPMailer' object has no attribute '_smtp'
```
All tests are passing for earlier version of Plone.

### What is my prediction: 
After day long investigation, I found [SMTPMailer __init__ method is patched here](https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/patches/sendmail.py#L39) , beside Also found that [zope.sendmail from version 4.1.0 the SMTPMailer's __init__](https://github.com/zopefoundation/zope.sendmail/blob/4.1.0/src/zope/sendmail/mailer.py#L45)
has been introduced a new attribute `_smtp` what is ignored during patching.

### How to reproduce:

This is only for Plone 5.2.x

1. disable Mock Mail
2. Try to send email from your tests code 
3. Or try send mail from your production/testing server.




--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `Products/CMFPlone/patches/sendmail.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 from plone.registry.interfaces import IRegistry
3 from Products.CMFPlone.interfaces import IMailSchema
4 from transaction._transaction import Status
5 from zope.component import getUtility
6 from zope.sendmail.mailer import SMTPMailer
7 
8 import logging
9 import transaction
10 
11 log = logging.getLogger("MailDataManager")
12 
13 
14 # BBB remove when zope.sendmail 3.8.0 is released.
15 def catchAllExceptions(func):
16     def _catch(*args, **kwargs):
17         try:
18             return func(*args, **kwargs)
19         except Exception as e:
20             txn = transaction.get()
21             if txn.status == Status.ACTIVE:
22                 # sent with immediate=True
23                 raise
24             else:
25                 # Avoid raising errors during tpc_finish as these could lead to
26                 # inconsistent state
27                 log.exception(e)
28 
29     return _catch
30 
31 
32 def applyPatches():
33     from zope.sendmail.mailer import SMTPMailer
34     old_mailer = getattr(SMTPMailer, 'vote', None) is None
35     if old_mailer:
36         SMTPMailer.send = catchAllExceptions(SMTPMailer.send)
37 
38 
39 def new_init(
40         self,
41         hostname='localhost',
42         port=25,
43         username=None,
44         password=None,
45         no_tls=False,
46         force_tls=False):
47 
48     registry = getUtility(IRegistry)
49     mail_settings = registry.forInterface(IMailSchema, prefix='plone')
50     self.hostname = mail_settings.smtp_host
51     self.port = mail_settings.smtp_port
52     self.username = mail_settings.smtp_userid
53     self.password = mail_settings.smtp_pass
54     self.force_tls = force_tls
55     self.no_tls = no_tls
56 
57 SMTPMailer.__init__ = new_init
58
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/Products/CMFPlone/patches/sendmail.py b/Products/CMFPlone/patches/sendmail.py
--- a/Products/CMFPlone/patches/sendmail.py
+++ b/Products/CMFPlone/patches/sendmail.py
@@ -3,11 +3,13 @@
 from Products.CMFPlone.interfaces import IMailSchema
 from transaction._transaction import Status
 from zope.component import getUtility
+from zope.sendmail.mailer import _SMTPState
 from zope.sendmail.mailer import SMTPMailer
 
 import logging
 import transaction
 
+
 log = logging.getLogger("MailDataManager")
 
 
@@ -53,5 +55,7 @@
     self.password = mail_settings.smtp_pass
     self.force_tls = force_tls
     self.no_tls = no_tls
+    self._smtp = _SMTPState()
+
 
 SMTPMailer.__init__ = new_init

{"golden_diff": "diff --git a/Products/CMFPlone/patches/sendmail.py b/Products/CMFPlone/patches/sendmail.py\n--- a/Products/CMFPlone/patches/sendmail.py\n+++ b/Products/CMFPlone/patches/sendmail.py\n@@ -3,11 +3,13 @@\n from Products.CMFPlone.interfaces import IMailSchema\n from transaction._transaction import Status\n from zope.component import getUtility\n+from zope.sendmail.mailer import _SMTPState\n from zope.sendmail.mailer import SMTPMailer\n \n import logging\n import transaction\n \n+\n log = logging.getLogger(\"MailDataManager\")\n \n \n@@ -53,5 +55,7 @@\n     self.password = mail_settings.smtp_pass\n     self.force_tls = force_tls\n     self.no_tls = no_tls\n+    self._smtp = _SMTPState()\n+\n \n SMTPMailer.__init__ = new_init\n", "issue": "Bug: `_smtp` is missing at SMTPMailer's __init__ patching what is introduced in zope.sendmail from version  4.1.0\n### What I did:\r\nI am working on internal Addon development (adding support for Plone 5.2) , sending mail notification one of the part functionalities. FYI: some how I forget to active MockMailhost.\r\nWhen I run all my existing unittests and  got unexpected errors : \r\n\r\n```\r\nFile \"/home/nazrul/.cache/buildout/eggs/plone.testing-7.0.0-py2.7.egg/plone/testing/zope.py\", line 859, in testTearDown\r\n    transaction.abort()\r\n  File \"/home/nazrul/.cache/buildout/eggs/transaction-2.4.0-py2.7.egg/transaction/_manager.py\", line 255, in abort\r\n    return self.manager.abort()\r\n  File \"/home/nazrul/.cache/buildout/eggs/transaction-2.4.0-py2.7.egg/transaction/_manager.py\", line 136, in abort\r\n    return self.get().abort()\r\n  File \"/home/nazrul/.cache/buildout/eggs/transaction-2.4.0-py2.7.egg/transaction/_transaction.py\", line 529, in abort\r\n    reraise(t, v, tb)\r\n  File \"/home/nazrul/.cache/buildout/eggs/transaction-2.4.0-py2.7.egg/transaction/_transaction.py\", line 515, in abort\r\n    rm.abort(self)\r\n  File \"/home/nazrul/.cache/buildout/eggs/zope.sendmail-4.2-py2.7.egg/zope/sendmail/delivery.py\", line 57, in abort\r\n    self.onAbort()\r\n  File \"/home/nazrul/.cache/buildout/eggs/zope.sendmail-4.2-py2.7.egg/zope/sendmail/mailer.py\", line 78, in abort\r\n    if self.connection is None:\r\n  File \"/home/nazrul/.cache/buildout/eggs/zope.sendmail-4.2-py2.7.egg/zope/sendmail/mailer.py\", line 48, in <lambda>\r\n    return property(lambda self: getattr(self._smtp, name),\r\nAttributeError: 'SMTPMailer' object has no attribute '_smtp'\r\n```\r\nAll tests are passing for earlier version of Plone.\r\n\r\n### What is my prediction: \r\nAfter day long investigation, I found [SMTPMailer __init__ method is patched here](https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/patches/sendmail.py#L39) , beside Also found that [zope.sendmail from version 4.1.0 the SMTPMailer's __init__](https://github.com/zopefoundation/zope.sendmail/blob/4.1.0/src/zope/sendmail/mailer.py#L45)\r\nhas been introduced a new attribute `_smtp` what is ignored during patching.\r\n\r\n### How to reproduce:\r\n\r\nThis is only for Plone 5.2.x\r\n\r\n1. disable Mock Mail\r\n2. Try to send email from your tests code \r\n3. Or try send mail from your production/testing server.\r\n\r\n\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nfrom plone.registry.interfaces import IRegistry\nfrom Products.CMFPlone.interfaces import IMailSchema\nfrom transaction._transaction import Status\nfrom zope.component import getUtility\nfrom zope.sendmail.mailer import SMTPMailer\n\nimport logging\nimport transaction\n\nlog = logging.getLogger(\"MailDataManager\")\n\n\n# BBB remove when zope.sendmail 3.8.0 is released.\ndef catchAllExceptions(func):\n    def _catch(*args, **kwargs):\n        try:\n            return func(*args, **kwargs)\n        except Exception as e:\n            txn = transaction.get()\n            if txn.status == Status.ACTIVE:\n                # sent with immediate=True\n                raise\n            else:\n                # Avoid raising errors during tpc_finish as these could lead to\n                # inconsistent state\n                log.exception(e)\n\n    return _catch\n\n\ndef applyPatches():\n    from zope.sendmail.mailer import SMTPMailer\n    old_mailer = getattr(SMTPMailer, 'vote', None) is None\n    if old_mailer:\n        SMTPMailer.send = catchAllExceptions(SMTPMailer.send)\n\n\ndef new_init(\n        self,\n        hostname='localhost',\n        port=25,\n        username=None,\n        password=None,\n        no_tls=False,\n        force_tls=False):\n\n    registry = getUtility(IRegistry)\n    mail_settings = registry.forInterface(IMailSchema, prefix='plone')\n    self.hostname = mail_settings.smtp_host\n    self.port = mail_settings.smtp_port\n    self.username = mail_settings.smtp_userid\n    self.password = mail_settings.smtp_pass\n    self.force_tls = force_tls\n    self.no_tls = no_tls\n\nSMTPMailer.__init__ = new_init\n", "path": "Products/CMFPlone/patches/sendmail.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nfrom plone.registry.interfaces import IRegistry\nfrom Products.CMFPlone.interfaces import IMailSchema\nfrom transaction._transaction import Status\nfrom zope.component import getUtility\nfrom zope.sendmail.mailer import _SMTPState\nfrom zope.sendmail.mailer import SMTPMailer\n\nimport logging\nimport transaction\n\n\nlog = logging.getLogger(\"MailDataManager\")\n\n\n# BBB remove when zope.sendmail 3.8.0 is released.\ndef catchAllExceptions(func):\n    def _catch(*args, **kwargs):\n        try:\n            return func(*args, **kwargs)\n        except Exception as e:\n            txn = transaction.get()\n            if txn.status == Status.ACTIVE:\n                # sent with immediate=True\n                raise\n            else:\n                # Avoid raising errors during tpc_finish as these could lead to\n                # inconsistent state\n                log.exception(e)\n\n    return _catch\n\n\ndef applyPatches():\n    from zope.sendmail.mailer import SMTPMailer\n    old_mailer = getattr(SMTPMailer, 'vote', None) is None\n    if old_mailer:\n        SMTPMailer.send = catchAllExceptions(SMTPMailer.send)\n\n\ndef new_init(\n        self,\n        hostname='localhost',\n        port=25,\n        username=None,\n        password=None,\n        no_tls=False,\n        force_tls=False):\n\n    registry = getUtility(IRegistry)\n    mail_settings = registry.forInterface(IMailSchema, prefix='plone')\n    self.hostname = mail_settings.smtp_host\n    self.port = mail_settings.smtp_port\n    self.username = mail_settings.smtp_userid\n    self.password = mail_settings.smtp_pass\n    self.force_tls = force_tls\n    self.no_tls = no_tls\n    self._smtp = _SMTPState()\n\n\nSMTPMailer.__init__ = new_init\n", "path": "Products/CMFPlone/patches/sendmail.py"}]}