Emails are not sent from the application

0

I am sending emails automatically from an application in python, run the whole process but the email is not sent, I hope you can help me, I leave the code

@csrf_exempt
def tickets_canalizacion(request):
    try:
        conexion = conexion_db()
        objeto = dict(request.POST.dict())

        canal_venta = objeto["canal_venta"]
        canal_venta = canal_venta["VALUE"]
        print canal_venta

        query='''
                SELECT CORREO "correo"
                FROM ATN_TICKETS_CANALIZACION
                WHERE ESTRUCTURA='{0}' AND 
                      TIPO_VENTA='{1}'
        '''.format(objeto["estructura"], canal_venta)
        #print query
        datos = consulta_asociativa(query, conexion["cursor"])[0]

        if validate_email(datos['correo']):
            email_template_name = 'atn/mail/atencion_tickets_web.html'
            subject = objeto['asunto']

            ctx = {
                'nombre': objeto['nombre'],
                'respuesta': objeto['respuesta'].replace('\n', '<br>')
            }

            email = render_to_string(email_template_name, ctx)
            send_mail(
                subject,
                objeto['respuesta'],
                '[email protected]',
                [datos['correo']],
                html_message=email
            )
        else:
            raise Exception({'status': 403,
                             'titulo': 'Error en el registro',
                             'message': 'Email invalido (403)'})

        response = {
            'status': 201,
            'titulo': 'Registro guardado',
            'mensaje': 'Se ha guardado con exito'
        }
    except Exception, e:
        response = {
            'status': 400,
            'titulo': 'Error',
            'mensaje': e.message
        }
    return HttpResponse(json.dumps(response), content_type="application/json")
    
asked by Jonathan Garcia 20.08.2018 в 16:38
source

0 answers