SMTP error (ERPNext 5.5.1)

Hello,

I have been trying to set up my outgoing email account on v5.5.1 but I get this error message.

I checked my credentials multiple times, they are ok. My server is SSL but I am not sure about TLS and it is the only option I have to tick. I have the same error if I tick it or not.

Traceback (innermost last):
  File "/home/administrator/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 18, in savedocs
    doc.save()
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 225, in save
    self.run_before_save_methods()
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 543, in run_before_save_methods
    self.run_method("validate")
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 509, in run_method
    return Document.hook(fn)(self, *args, **kwargs)
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 625, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 608, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 503, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 52, in validate
    self.check_smtp()
  File "/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 93, in check_smtp
    server.sess
  File "/home/administrator/frappe-bench/apps/frappe/frappe/email/smtp.py", line 143, in sess
    cint(self.port) or None)
  File "/usr/lib/python2.7/smtplib.py", line 249, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.7/smtplib.py", line 310, in connect
    (code, msg) = self.getreply()
  File "/usr/lib/python2.7/smtplib.py", line 361, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
 SMTPServerDisconnected: Connection unexpectedly closed

Traceback (innermost last):
  File "/home/administrator/frappe-bench/apps/frappe/frappe/app.py", line 51, in application
    response = frappe.handler.handle()
  File "/home/administrator/frappe-bench/apps/frappe/frappe/handler.py", line 69, in handle
    execute_cmd(cmd)
  File "/home/administrator/frappe-bench/apps/frappe/frappe/handler.py", line 92, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/administrator/frappe-bench/apps/frappe/frappe/__init__.py", line 751, in call
    return fn(*args, **newargs)
  File "/home/administrator/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 18, in savedocs
    doc.save()
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 225, in save
    self.run_before_save_methods()
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 543, in run_before_save_methods
    self.run_method("validate")
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 509, in run_method
    return Document.hook(fn)(self, *args, **kwargs)
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 625, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 608, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py", line 503, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 52, in validate
    self.check_smtp()
  File "/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 93, in check_smtp
    server.sess
  File "/home/administrator/frappe-bench/apps/frappe/frappe/email/smtp.py", line 143, in sess
    cint(self.port) or None)
  File "/usr/lib/python2.7/smtplib.py", line 249, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.7/smtplib.py", line 310, in connect
    (code, msg) = self.getreply()
  File "/usr/lib/python2.7/smtplib.py", line 361, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
 SMTPServerDisconnected: Connection unexpectedly closed

Am I missing something?

Thank for your help on this.

Seems like an issue with the service provider or you may have firewalls

I think I had this error as well.
Did you try adding their ProTip text?

ProTip: Add Reference: {{ reference_doctype }} {{ reference_name }} to send document reference

If you enter it verbatim, you will get an error when you save the page.