Ejemplo n.º 1
0
def no_content_message():
    m = Message()
    m.set_sender('*****@*****.**', 'Regular Sender')
    m.subject = "Very important"
    m.add_recipient('other.userdomain.com', 'Regular Recipient')
    m.add_cc('*****@*****.**', 'Mario Dimitrov')
    m.add_bcc('*****@*****.**')
    return m
Ejemplo n.º 2
0
def no_recipient_has_cc_bcc():
    m = Message()
    m.set_sender('*****@*****.**', 'Regular Sender')
    m.add_cc('*****@*****.**', 'Mario Dimitrov')
    m.add_bcc('*****@*****.**')
    m.text = "Just spam"
    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 no_recipient_has_cc_bcc():
    m = Message()
    m.set_sender('*****@*****.**', 'Regular Sender')
    m.add_cc('*****@*****.**', 'Mario Dimitrov')
    m.add_bcc('*****@*****.**')
    m.text = "Just spam"
    return m
Ejemplo n.º 5
0
def unicode_message():
    m = Message()
    m.set_sender('*****@*****.**', 'Изпращач')
    m.add_recipient('*****@*****.**', 'Марио Димитров')
    m.subject = "முக்கியமான செய்தி"
    m.text = "你好邮件服务"
    return m
Ejemplo n.º 6
0
def bad_message_wrong_address():
    m = Message()
    m.set_sender('*****@*****.**', 'Regular Sender')
    m.add_recipient('other.userdomain.com', 'Regular Recipient')
    m.subject = "Very important"
    m.text = "Another spam message"
    return m
Ejemplo n.º 7
0
 def __create_message(self):
     m = Message()
     m.set_sender('*****@*****.**', 'Regular Sender')
     m.add_recipient('*****@*****.**', 'Regular Recipient')
     m.subject = "Very important"
     m.text = "Another spam message"
     return m
Ejemplo n.º 8
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.º 9
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.º 10
0
def bad_message_wrong_address():
    m = Message()
    m.set_sender('*****@*****.**', 'Regular Sender')
    m.add_recipient('other.userdomain.com', 'Regular Recipient')
    m.subject = "Very important"
    m.text = "Another spam message"
    return m
Ejemplo n.º 11
0
def unicode_message():
    m = Message()
    m.set_sender('*****@*****.**', 'Изпращач')
    m.add_recipient('*****@*****.**', 'Марио Димитров')
    m.subject = "முக்கியமான செய்தி"
    m.text = "你好邮件服务"
    return m
Ejemplo n.º 12
0
 def __create_message(self):
     m = Message()
     m.set_sender('*****@*****.**', 'Regular Sender')
     m.add_recipient('*****@*****.**', 'Regular Recipient')
     m.subject = "Very important"
     m.text = "Another spam message"
     return m
Ejemplo n.º 13
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.º 14
0
 def test_simple_message_creation(self):
     message = Message()
     message.simple_message('*****@*****.**', '*****@*****.**', 'Another spam message')
     self.assertEqual(message.text, 'Another spam message')
Ejemplo n.º 15
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.º 16
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.º 17
0
def no_content_message():
    m = Message()
    m.set_sender('*****@*****.**', 'Regular Sender')
    m.subject = "Very important"
    m.add_recipient('other.userdomain.com', 'Regular Recipient')
    m.add_cc('*****@*****.**', 'Mario Dimitrov')
    m.add_bcc('*****@*****.**')
    return m
Ejemplo n.º 18
0
 def test_simple_message_creation(self):
     message = Message()
     message.simple_message('*****@*****.**', '*****@*****.**',
                            'Another spam message')
     self.assertEqual(message.text, 'Another spam message')