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)