Ejemplo n.º 1
0
def no_recipients_message():
    m = Message()
    m.set_sender('*****@*****.**', 'Regular Sender')
    m.subject = "Very important"
    m.text = "Another spam message"
    m.body = "<h2> Very important for you </h2>"
    return m
Ejemplo n.º 2
0
def no_recipients_message():
    m = Message()
    m.set_sender('*****@*****.**', 'Regular Sender')
    m.subject = "Very important"
    m.text = "Another spam message"
    m.body = "<h2> Very important for you </h2>"
    return m
Ejemplo n.º 3
0
def good_message_single_recipient():
    m = Message()
    m.set_sender('*****@*****.**', 'Regular Sender')
    m.add_recipient('*****@*****.**', 'Regular Richtext Recipient')
    m.subject = "Very important"
    m.text = "Another spam message"
    m.body = "<h2> Very important for you </h2>"
    return m
Ejemplo n.º 4
0
def good_message_single_recipient():
    m = Message()
    m.set_sender('*****@*****.**', 'Regular Sender')
    m.add_recipient('*****@*****.**', 'Regular Richtext Recipient')
    m.subject = "Very important"
    m.text = "Another spam message"
    m.body = "<h2> Very important for you </h2>"
    return m
Ejemplo n.º 5
0
def send_mail():
    """
    Tries to construct a message from the passed arguments,
    validates it and passes it to the MessageService for sending
    :return: Success status and result message
    In case the message did not fulfill the criteria returns a message with the first failure
    Read more at
    https://github.com/mariodmtrv/RobustMail/wiki#send-a-message
    """
    data = request.get_json()
    message = Message()
    if "sender" in data and data["sender"] is not None:
        result = gen_email_user(data["sender"])
        if result is not None:
            message.set_sender(result[0], result[1])
    if "subject" in data and data["subject"] is not None:
        message.subject = data["subject"]
    if "text" in data and data["text"] is not None:
        message.text = data["text"]
    if "recipients" in data and data["recipients"] is not None and len(
            data["recipients"]) > 0:
        for recipient in data["recipients"]:
            result = gen_email_user(recipient)
            if result is not None:
                message.add_recipient(result[0], result[1])
    if 'cc' in data and data["cc"] is not None and len(data["cc"]) > 0:
        for recipient in data["cc"]:
            result = gen_email_user(recipient)
            if result is not None:
                message.add_cc(result[0], result[1])
    if "bcc" in data and data["bcc"] is not None and len(data["bcc"]) > 0:
        for recipient in data["bcc"]:
            result = gen_email_user(recipient)
            if result is not None:
                message.add_bcc(result[0], result[1])
    if "body" in data and data["body"] is not None:
        message.body = data["body"]
    is_valid = message.validate()
    if not is_valid[0]:
        return SendEmailResponse(is_valid[0], is_valid[1]).to_JSON()
    result = send_message.delay(message_service, message)
    return SendEmailResponse(True,
                             "Message accepted for processing!").to_JSON()
Ejemplo n.º 6
0
def send_mail():
    """
    Tries to construct a message from the passed arguments,
    validates it and passes it to the MessageService for sending
    :return: Success status and result message
    In case the message did not fulfill the criteria returns a message with the first failure
    Read more at
    https://github.com/mariodmtrv/RobustMail/wiki#send-a-message
    """
    data = request.get_json()
    message = Message()
    if "sender" in data and data["sender"] is not None:
        result = gen_email_user(data["sender"])
        if result is not None:
            message.set_sender(result[0], result[1])
    if "subject" in data and data["subject"] is not None:
        message.subject = data["subject"]
    if "text" in data and data["text"] is not None:
        message.text = data["text"]
    if "recipients" in data and data["recipients"] is not None and len(data["recipients"]) > 0:
        for recipient in data["recipients"]:
            result = gen_email_user(recipient)
            if result is not None:
                message.add_recipient(result[0], result[1])
    if 'cc' in data and data["cc"] is not None and len(data["cc"]) > 0:
        for recipient in data["cc"]:
            result = gen_email_user(recipient)
            if result is not None:
                message.add_cc(result[0], result[1])
    if "bcc" in data and data["bcc"] is not None and len(data["bcc"]) > 0:
        for recipient in data["bcc"]:
            result = gen_email_user(recipient)
            if result is not None:
                message.add_bcc(result[0], result[1])
    if "body" in data and data["body"] is not None:
        message.body = data["body"]
    is_valid = message.validate()
    if not is_valid[0]:
        return SendEmailResponse(is_valid[0], is_valid[1]).to_JSON()
    result = send_message.delay(message_service, message)
    return SendEmailResponse(True, "Message accepted for processing!").to_JSON()