コード例 #1
0
ファイル: mailinglist_tests.py プロジェクト: 3kwa/lamson
def test_craft_response_attachment():
    sample = MailResponse(To=list_name + "@librelist.com",
                          From=user_full_address,
                          Subject="Test message with attachments.",
                          Body="The body as one attachment.")

    sample.attach(filename="tests/model/mailinglist_tests.py",
                  content_type="text/plain",
                  disposition="attachment")

    sample['message-id'] = '123545666'

    im = sample.to_message()
    assert_equal(len([x for x in im.walk()]), 3)
    
    inmsg = MailRequest("fakepeer", None, None, str(sample))
    assert_equal(len(inmsg.all_parts()), 2)

    outmsg = craft_response(inmsg, list_name, list_name +
                                        "@librelist.com")
  
    om = outmsg.to_message()

    assert_equal(len([x for x in om.walk()]),
                 len([x for x in im.walk()]))

    assert 'message-id' in outmsg
コード例 #2
0
def test_craft_response_attachment():
    sample = MailResponse(To=list_name + "@librelist.com",
                          From=user_full_address,
                          Subject="Test message with attachments.",
                          Body="The body as one attachment.")

    sample.attach(filename="tests/model/mailinglist_tests.py",
                  content_type="text/plain",
                  disposition="attachment")

    sample['message-id'] = '123545666'

    im = sample.to_message()
    assert_equal(len([x for x in im.walk()]), 3)

    inmsg = MailRequest("fakepeer", None, None, str(sample))
    assert_equal(len(inmsg.all_parts()), 2)

    outmsg = craft_response(inmsg, list_name, list_name + "@librelist.com")

    om = outmsg.to_message()

    assert_equal(len([x for x in om.walk()]), len([x for x in im.walk()]))

    assert 'message-id' in outmsg
コード例 #3
0
def test_craft_response_no_attachment():
    sample = MailResponse(To=list_name + "@librelist.com",
                          From=user_full_address,
                          Subject="Test message with attachments.",
                          Body="The body as one attachment.")

    im = sample.to_message()
    assert_equal(len([x for x in im.walk()]), 1)
    assert_equal(im.get_payload(), sample.Body)

    inmsg = MailRequest("fakepeer", None, None, str(sample))
    assert_equal(len(inmsg.all_parts()), 0)
    assert_equal(inmsg.body(), sample.Body)

    outmsg = craft_response(inmsg, list_name, list_name + "@librelist.com")

    om = outmsg.to_message()
    assert_equal(om.get_payload(), sample.Body)

    assert_equal(len([x for x in om.walk()]), len([x for x in im.walk()]))
コード例 #4
0
ファイル: mailinglist_tests.py プロジェクト: 3kwa/lamson
def test_craft_response_no_attachment():
    sample = MailResponse(To=list_name + "@librelist.com",
                          From=user_full_address,
                          Subject="Test message with attachments.",
                          Body="The body as one attachment.")

    im = sample.to_message()
    assert_equal(len([x for x in im.walk()]), 1)
    assert_equal(im.get_payload(), sample.Body)
    
    inmsg = MailRequest("fakepeer", None, None, str(sample))
    assert_equal(len(inmsg.all_parts()), 0)
    assert_equal(inmsg.body(), sample.Body)

    outmsg = craft_response(inmsg, list_name, list_name +
                                        "@librelist.com")
  
    om = outmsg.to_message()
    assert_equal(om.get_payload(), sample.Body)

    assert_equal(len([x for x in om.walk()]),
                 len([x for x in im.walk()]))
コード例 #5
0
ファイル: imapidle.py プロジェクト: athoune/imapidle
        raise Exception("IDLE not handled? : %s" % response)


def done(connection):
    connection.send("DONE\r\n")
    connection.loop = False

imaplib.IMAP4.idle = idle
imaplib.IMAP4.done = done

if __name__ == '__main__':
    import os
    from lamson.mail import MailRequest
    user = os.environ['EMAIL']
    password = os.environ['PASSWORD']
    print os.environ['SERVER']
    conn = imaplib.IMAP4_SSL(os.environ['SERVER'])
    conn.login(user, password)
    conn.select()
    loop = True
    while loop:
        for uid, msg in conn.idle():
            print uid, msg
            if msg == "EXISTS":
                conn.done()
                status, datas = conn.fetch(uid, '(RFC822)')
                m = MailRequest('localhost', None, None, datas[0][1])
                print m.keys()
                print m.all_parts()
                print m.is_bounce()
コード例 #6
0

def done(connection):
    connection.send("DONE\r\n".encode('utf8'))
    connection.loop = False


imaplib.IMAP4.idle = idle
imaplib.IMAP4.done = done

if __name__ == '__main__':
    import os
    from lamson.mail import MailRequest
    user = os.environ['EMAIL']
    password = os.environ['PASSWORD']
    print(os.environ['SERVER'])
    conn = imaplib.IMAP4_SSL(os.environ['SERVER'])
    conn.login(user, password)
    conn.select()
    loop = True
    while loop:
        for uid, msg in conn.idle():
            print(uid, msg)
            if msg == "EXISTS":
                conn.done()
                status, datas = conn.fetch(uid, '(RFC822)')
                m = MailRequest('localhost', None, None, datas[0][1])
                print(m.keys())
                print(m.all_parts())
                print(m.is_bounce())
コード例 #7
0
ファイル: imapidle.py プロジェクト: emberai/prototype

def done(connection):
    connection.send("DONE\r\n")
    connection.loop = False


imaplib.IMAP4.idle = idle
imaplib.IMAP4.done = done

if __name__ == '__main__':
    import os
    from lamson.mail import MailRequest
    user = os.environ['EMAIL']
    password = os.environ['PASSWORD']
    print os.environ['SERVER']
    conn = imaplib.IMAP4_SSL(os.environ['SERVER'])
    conn.login(user, password)
    conn.select()
    loop = True
    while loop:
        for uid, msg in conn.idle():
            print uid, msg
            if msg == "EXISTS":
                conn.done()
                status, datas = conn.fetch(uid, '(RFC822)')
                m = MailRequest('localhost', None, None, datas[0][1])
                print m.keys()
                print m.all_parts()
                print m.is_bounce()