zatosource / zato

ESB, SOA, REST, APIs and Cloud Integrations in Python
https://zato.io
GNU Affero General Public License v3.0
1.12k stars 240 forks source link

SMTP failed when use SSL mode #1130

Closed bbqi closed 3 years ago

bbqi commented 3 years ago

When I used SMTP with SSL mode, got some error:

2021-02-20 02:53:24,161 - WARNING - 219:DummyThread-432 - zato.server.connection.email:0 - Could not send an SMTP message to `Bunch(action='104801', cluster_id=1, host='smtp.exmail.qq.com', id=1, is_active=True, is_debug=True, mode='ssl', msg_type='0002', name='Exmail', old_name='Exmail', opaque1=None, password='******', ping_address='***@****', port=465, timeout=30, username='****@****')`, e:`Traceback (most recent call last):
  File "/opt/zato/3.2.0/code/zato-server/src/zato/server/connection/email.py", line 153, in send
    with self.conn_class(*self.conn_args) as conn:
  File "/opt/zato/3.2.0/code/zato-server/src/zato/server/ext/outbox.py", line 159, in __enter__
    self.connect()
  File "/opt/zato/3.2.0/code/zato-server/src/zato/server/ext/outbox.py", line 186, in connect
    self._conn = self._login()
  File "/opt/zato/3.2.0/code/zato-server/src/zato/server/ext/outbox.py", line 175, in _login
    smtp = smtp_class(server, port, timeout=timeout)
  File "/usr/lib/python3.8/smtplib.py", line 1034, in __init__
    SMTP.__init__(self, host, port, local_hostname, timeout,
  File "/usr/lib/python3.8/smtplib.py", line 253, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python3.8/smtplib.py", line 339, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python3.8/smtplib.py", line 1042, in _get_socket
    new_socket = self.context.wrap_socket(new_socket,
  File "/opt/zato/3.2.0/code/lib/python3.8/site-packages/gevent/_ssl3.py", line 113, in wrap_socket
    return self.sslsocket_class(
  File "/opt/zato/3.2.0/code/lib/python3.8/site-packages/gevent/_ssl3.py", line 300, in __init__
    self._sslobj = self.__create_sslobj(server_side, _session)
  File "/opt/zato/3.2.0/code/lib/python3.8/site-packages/gevent/_ssl3.py", line 687, in __create_sslobj
    return self.context._wrap_socket(
TypeError: argument must be str, not bytes

When I use SMTP with plain Mode(port:25), It's OK.

zato version: 3.2+rev.f79297b-py3.8.5

dsuch commented 3 years ago

Thanks, I will check it.

dsuch commented 3 years ago

Hello @bbqi - I tried to reproduce this situation but I am unable to.

Please make sure that you have the latest updates and try again https://zato.io/docs/3.2/admin/guide/install/update.html

If you still get an exception, please provide all the details of your connection, not just the traceback. Otherwise, I just do not know what your configuration is.

Thank you.

dsuch commented 3 years ago

Closing due to inactivity. @bbqi - please feel free to reopen when you have all the details that I requested earlier. Thank you.