def __init__(self, amount_of_letters=10):
        self.latest_letters = ezgmail.recent(maxResults=amount_of_letters)

        import os
        os.environ["Mail_env"] = 'true'
        from django.core.wsgi import get_wsgi_application
        os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'the_site.settings')
        application = get_wsgi_application()
        os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = 'true'
Example #2
0
def test_basic():
    assert ezgmail.EMAIL_ADDRESS == TEST_EMAIL_ADDRESS

    attachmentFilename = os.path.join(
        os.path.dirname(os.path.realpath(__file__)), 'attachment.txt')

    # This test doesn't check the results, it just makes sure these functions don't raise any exceptions:
    ezgmail.send(TEST_EMAIL_ADDRESS, TEST_SUBJECT,
                 'This is the body of the email.', [attachmentFilename])
    unreadThreads = ezgmail.unread()
    unreadThreads[
        0]  # NOTE: Make sure the test email account always has at least one unread message.
    ezgmail.summary(unreadThreads, printInfo=False)
    recentThreads = ezgmail.recent()
    msg = recentThreads[0].messages[0]
    msg.sender
    msg.recipient
    msg.subject
    msg.body
    msg.timestamp
    ezgmail.search('mancala')
Example #3
0
import ezgmail
#ezgmail.init()
#ezgmail.send("*****@*****.**","test mail", "Pls respond")
recent_mails = ezgmail.recent()
recursive_string = ""
for mails in recent_mails:
    recursive_string += mails.snippet + "\n"

print(recursive_string)

ezgmail.send("*****@*****.**", "Recursive", recursive_string)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 13 17:52:32 2020

@author: tylerkim


"""
import ezgmail, os

# prints list of unread emails
unreadThreads = ezgmail.unread()  # List of GmailThread objects.
ezgmail.summary(unreadThreads)

len(unreadThreads)  # number of unread emails

# Will probably use this more often
recentThreads = ezgmail.recent(maxResults=100)
len(recentThreads)

for i in range(len(unreadThreads)):
    print('SUB: ' + unreadThreads[0].messages[0].subject)
    print('BODY: ' + unreadThreads[0].messages[0].body)

firstEmail = ezgmail.search('subject:FIRST EMAIL')
import ezgmail

unreadThreads = ezgmail.unread()  # List of GmailThread objects.
print(ezgmail.summary(unreadThreads))

print(len(unreadThreads))
print(str(unreadThreads[0]))
print(len(unreadThreads[0].messages))
print(str(unreadThreads[0].messages[0]))
print(unreadThreads[0].messages[0].subject)
print(unreadThreads[0].messages[0].body)
print(unreadThreads[0].messages[0].timestamp)
print(unreadThreads[0].messages[0].sender)
print(unreadThreads[0].messages[0].recipient)

recentThreads = ezgmail.recent()  # default: 25
print(len(recentThreads))
recentThreads = ezgmail.recent(maxResults=100)
print(len(recentThreads))
#!python3
# chapter.py

import ezgmail, os
#ezgmail.init()
#print(ezgmail.EMAIL_ADDRESS)
unreadThreads = ezgmail.unread()
#print(ezgmail.summary(unreadThreads))
#print(len(unreadThreads))
#print(str(unreadThreads[0]))
print(unreadThreads[0].messages[0].subject)
#print(unreadThreads[0].messages[0].body)
print(unreadThreads[0].messages[0].timestamp)
print(unreadThreads[0].messages[0].sender)
print(unreadThreads[0].messages[0].recipient)

recentThread = ezgmail.recent(maxResults=1)
print(len(recentThread))
print(recentThread[0].messages[0].subject)