Agregar opción STARTTLS para envío de correo

This commit is contained in:
El Mau 2022-01-19 15:03:26 -06:00
commit ff8bc31f50
7 changed files with 21 additions and 10 deletions

View File

@ -1,4 +1,12 @@
v 1.44.2 [19-Ene-2022]
----------------------
- Agregar opción STARTTLS que requieren algunos servidores de correo
* IMPORTANTE: Revisa tu configuración de correo para verificar si tienes que usar esta opción.
v 1.44.1 [19-Ene-2022]
----------------------
- Correciones en generación de Carta Porte v2.0
- Plantilla para representación impresa de Carta Porte v2.0

View File

@ -1,2 +1,2 @@
1.44.1
1.44.2

View File

@ -269,9 +269,7 @@ class SendMail(object):
def _login(self):
try:
if self._config['ssl'] and (
'gmail' in self._config['servidor'] or
'outlook' in self._config['servidor']):
if self._config['ssl'] and self._config['starttls']:
self._server = smtplib.SMTP(
self._config['servidor'],
self._config['puerto'], timeout=10)

View File

@ -30,6 +30,7 @@ import shlex
import shutil
import smtplib
import sqlite3
import ssl
import subprocess
import threading
import unicodedata
@ -180,10 +181,8 @@ class SendMail(object):
return self._error
def _login(self):
hosts = ('gmail' in self._config['server'] or
'outlook' in self._config['server'])
try:
if self._config['ssl'] and hosts:
if self._config['ssl'] and self._config['starttls']:
self._server = smtplib.SMTP(
self._config['server'],
self._config['port'], timeout=TIMEOUT)

View File

@ -518,7 +518,8 @@ class Configuracion(BaseModel):
return values
def _get_correo(self, args={}):
fields = ('correo_servidor', 'correo_puerto', 'correo_ssl',
fields = ('correo_servidor', 'correo_puerto',
'correo_ssl', 'correo_starttls',
'correo_usuario', 'correo_copia', 'correo_asunto',
'correo_mensaje', 'correo_directo', 'correo_confirmacion')
data = (Configuracion
@ -4889,6 +4890,7 @@ class Facturas(BaseModel):
'servidor': values['correo_servidor'],
'puerto': values['correo_puerto'],
'ssl': bool(int(values['correo_ssl'])),
'starttls': bool(int(values['correo_starttls'])),
'usuario': values['correo_usuario'],
'contra': utils.decrypt(contra, rfc),
}
@ -10292,6 +10294,7 @@ def _send_notify_access(args):
'server': config['correo_servidor'],
'port': config['correo_puerto'],
'ssl': utils.to_bool(config['correo_ssl']),
'starttls': utils.to_bool(config['correo_starttls']),
'user': config['correo_usuario'],
'pass': utils.decrypt(contra, rfc),
}
@ -10403,6 +10406,7 @@ def test_correo(values):
'servidor': values['correo_servidor'],
'puerto': values['correo_puerto'],
'ssl': util.get_bool(values['correo_ssl']),
'starttls': util.get_bool(values['correo_starttls']),
'usuario': values['correo_usuario'],
'contra': values['correo_contra'],
}

View File

@ -42,7 +42,7 @@ except ImportError:
DEBUG = DEBUG
VERSION = '1.44.1'
VERSION = '1.44.2'
EMAIL_SUPPORT = ('soporte@empresalibre.mx',)
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)

View File

@ -483,7 +483,9 @@ var emisor_correo = [
{}]},
{cols: [
{view: 'checkbox', id: 'correo_ssl', name: 'correo_ssl',
label: 'Usar TLS/SSL: '},
label: 'Usar TLS/SSL: ', maxWidth: 210},
{view: 'checkbox', id: 'correo_starttls', name: 'correo_starttls',
label: 'Usar STARTTLS: '},
{}]},
{cols: [
{view: 'text', id: 'correo_usuario', name: 'correo_usuario',