コード例 #1
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
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
コード例 #2
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
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
コード例 #3
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
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
コード例 #4
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
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
コード例 #5
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
def unicode_message():
    m = Message()
    m.set_sender('*****@*****.**', 'Изпращач')
    m.add_recipient('*****@*****.**', 'Марио Димитров')
    m.subject = "முக்கியமான செய்தி"
    m.text = "你好邮件服务"
    return m
コード例 #6
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
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
コード例 #7
0
ファイル: test_message.py プロジェクト: mariodmtrv/RobustMail
 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
コード例 #8
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
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
コード例 #9
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
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
コード例 #10
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
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
コード例 #11
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
def unicode_message():
    m = Message()
    m.set_sender('*****@*****.**', 'Изпращач')
    m.add_recipient('*****@*****.**', 'Марио Димитров')
    m.subject = "முக்கியமான செய்தி"
    m.text = "你好邮件服务"
    return m
コード例 #12
0
ファイル: test_message.py プロジェクト: mariodmtrv/RobustMail
 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
コード例 #13
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
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
コード例 #14
0
ファイル: test_message.py プロジェクト: mariodmtrv/RobustMail
 def test_simple_message_creation(self):
     message = Message()
     message.simple_message('*****@*****.**', '*****@*****.**', 'Another spam message')
     self.assertEqual(message.text, 'Another spam message')
コード例 #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()
コード例 #16
0
ファイル: RobustMail.py プロジェクト: mariodmtrv/RobustMail
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()
コード例 #17
0
ファイル: testing_data.py プロジェクト: mariodmtrv/RobustMail
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
コード例 #18
0
ファイル: test_message.py プロジェクト: mariodmtrv/RobustMail
 def test_simple_message_creation(self):
     message = Message()
     message.simple_message('*****@*****.**', '*****@*****.**',
                            'Another spam message')
     self.assertEqual(message.text, 'Another spam message')