Exemple #1
0
def send_email_process(msg_obj, connected_instance=None):
    """
    发送
    :param msg:
    :param connected_instance: 已连接的实例
    :return:
    """
    result_msg = "Send a success"
    try:
        if connected_instance:
            r = connected_instance.send(msg_obj)
        else:
            r = mail.send(msg_obj)
        if not r:
            status = "successful"
        else:
            status = "abnormal"
    except Exception as e:
        result_msg = str(e)
        status = "error"
    log = {
        "type": "email",
        "error_info": result_msg,
        'status': status,
        'subject': msg_obj.subject,
        'from': msg_obj.sender,
        'to': list(msg_obj.send_to),
        'date': msg_obj.date,
        'body': msg_obj.body,
        'html': msg_obj.html,
        'msgid': msg_obj.msgId,
        'time': time.time()
    }
    mdbs["sys"].db.sys_message.insert_one(log)
Exemple #2
0
def send_email_process(msg_obj, connected_instance=None):
    """
    发送
    :param msg:
    :param connected_instance: 已连接的实例
    :return:
    """
    result_msg = "Send a success"
    try:
        if connected_instance:
            r = connected_instance.send(msg_obj)
        else:
            r = mail.send(msg_obj)
        if not r:
            status = "successful"
        else:
            status = "abnormal"
    except Exception as e:
        result_msg = str(e)
        status = "error"

    return status, result_msg
Exemple #3
0
def send_email_process(msg, connected_instance=None):
    """
    发送
    :param msg:
    :param connected_instance: 已连接的实例
    :return:
    """
    error_info = None
    try:
        if connected_instance:
            r = connected_instance.send(msg)
        else:
            r = mail.send(msg)
        if not r:
            status = "normal"
        else:
            status = "abnormal"
    except Exception as e:
        error_info = json.dumps(str(e))
        status = "error"

    log = {
        "type": "email",
        "error_info": error_info,
        'status': status,
        'subject': msg.subject,
        'from': msg.sender,
        'to': list(msg.send_to),
        'date': msg.date,
        'body': msg.body,
        'html': msg.html,
        'msgid': msg.msgId,
        'time': time.time()
    }
    mdbs["sys"].db.sys_message.insert_one(log)
    if not status:
        return 0
    else:
        return -1