From 77e9e0ab00b40aca61e58bbab3916eb5ff7333a6 Mon Sep 17 00:00:00 2001 From: Israel Figueroa Date: Fri, 21 Jan 2022 20:36:16 -0300 Subject: [PATCH] TLS port 25 --- mayordomo/__init__.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/mayordomo/__init__.py b/mayordomo/__init__.py index 93df2b5..b475e36 100644 --- a/mayordomo/__init__.py +++ b/mayordomo/__init__.py @@ -47,13 +47,35 @@ async def enviarCorreosDominio(dominioid): try: conectado = False try: - smtp = aiosmtplib.SMTP(hostname=str(dbdireccion.ipaddr), source_address=banner_hostname, port=465, use_tls=True, validate_certs=True, client_cert=certfile, client_key=keyfile, cert_bundle=cacerts, timeout=10) + smtp = aiosmtplib.SMTP(hostname=str(dbdireccion.ipaddr), source_address=banner_hostname, port=25, use_tls=True, start_tls=False, validate_certs=True, client_cert=certfile, client_key=keyfile, cert_bundle=cacerts, timeout=10) await smtp.connect() conectado = True - await log.debug('Conectado a USE_TLS: {}'.format(dbdireccion.ipaddr)) + await log.debug('Conectado a USE_TLS: 25 {}'.format(dbdireccion.ipaddr)) except Exception as e: conectado = False - await log.debug('Error al conectar al servidor use_tls: {}'.format(e)) + await log.debug('Error al conectar al servidor use_tls 25: {}'.format(e)) + + if conectado == False: + try: + smtp = aiosmtplib.SMTP(hostname=str(dbdireccion.ipaddr), source_address=banner_hostname, port=25, start_tls=True, use_tls=False, validate_certs=True, client_cert=certfile, client_key=keyfile, cert_bundle=cacerts, timeout=10) + await smtp.connect() + await smtp.starttls() + conectado = True + await log.debug('Conectado a START_TLS: 25 {}'.format(dbdireccion.ipaddr)) + except Exception as e: + conectado = False + await log.debug('Error al conectar al servidor start_tls 25: {}'.format(e)) + + if conectado == False: + try: + smtp = aiosmtplib.SMTP(hostname=str(dbdireccion.ipaddr), source_address=banner_hostname, port=465, use_tls=True, validate_certs=True, client_cert=certfile, client_key=keyfile, cert_bundle=cacerts, timeout=10) + await smtp.connect() + await smtp.starttls() + conectado = True + await log.debug('Conectado a START_TLS 456: {}'.format(dbdireccion.ipaddr)) + except Exception as e: + conectado = False + await log.debug('Error al conectar al servidor start_tls 465: {}'.format(e)) if conectado == False: try: @@ -64,7 +86,8 @@ async def enviarCorreosDominio(dominioid): await log.debug('Conectado a START_TLS: {}'.format(dbdireccion.ipaddr)) except Exception as e: conectado = False - await log.debug('Error al conectar al servidor start_tls: {}'.format(e)) + await log.debug('Error al conectar al servidor start_tls 587: {}'.format(e)) + if conectado == False: try: smtp = aiosmtplib.SMTP(hostname=str(dbdireccion.ipaddr), timeout=10)