From 06324d49b5f6df377860665b1e5075c42cd81062 Mon Sep 17 00:00:00 2001 From: Gecko144 <74276056+Gecko144@users.noreply.github.com> Date: Fri, 18 Dec 2020 20:12:04 +0100 Subject: [PATCH 1/5] Update README.rst added clearer explanations --- README.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 8f25929..7951ae0 100644 --- a/README.rst +++ b/README.rst @@ -21,14 +21,21 @@ Example Usage ------------- Create session using auto-assigned email address, print email address and print -id of first message in inbox: +id of latest message in inbox: .. code-block:: python from guerrillamail import GuerrillaMailSession session = GuerrillaMailSession() - print session.get_session_state()['email_address'] - print session.get_email_list()[0].guid + current_email_address = session.get_session_state()['email_address'] #this is the current email address (type string) + print current_email_address + inbox = session.get_email_list() #get a list of all received emails + last_received_email = inbox[0] #each new email is appended to the beginning of the inbox list; therefore, the latest received email always has position [0] + guid = last_received_email.guid #each mail object is identified by its unique guid + email = session.get_email(guid) #this function needs to be called with guid as argument in order for a mail to be read; otherwise, the email body will be None + print email.guid, email.sender, email.subject, email.body, email.read #print some properties of the Mail ojbect + + Example CLI Usage From f62f2a9e224babd09ae518965a19cf791fa271bf Mon Sep 17 00:00:00 2001 From: Gecko144 <74276056+Gecko144@users.noreply.github.com> Date: Fri, 18 Dec 2020 20:16:24 +0100 Subject: [PATCH 2/5] Update README.rst --- README.rst | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 7951ae0..65722e3 100644 --- a/README.rst +++ b/README.rst @@ -29,11 +29,23 @@ id of latest message in inbox: session = GuerrillaMailSession() current_email_address = session.get_session_state()['email_address'] #this is the current email address (type string) print current_email_address - inbox = session.get_email_list() #get a list of all received emails - last_received_email = inbox[0] #each new email is appended to the beginning of the inbox list; therefore, the latest received email always has position [0] - guid = last_received_email.guid #each mail object is identified by its unique guid - email = session.get_email(guid) #this function needs to be called with guid as argument in order for a mail to be read; otherwise, the email body will be None - print email.guid, email.sender, email.subject, email.body, email.read #print some properties of the Mail ojbect + + #get a list of all received emails + inbox = session.get_email_list() + + #each new email is appended to the beginning of the inbox list; + #therefore, the latest received email always has position [0] + latest_received_email = inbox[0] + + #each mail object is identified by its unique guid + guid = latest_received_email.guid + + #Execute get_email function with guid as argument: this function needs to be called in order for a mail to be read; + #otherwise, the email body will be None. + email = session.get_email(guid) + + #print some properties of the Mail object + print email.guid, email.sender, email.subject, email.body, email.read From 13ada3c5e5823f4d2a9cc69638172108103e23f2 Mon Sep 17 00:00:00 2001 From: Gecko144 <74276056+Gecko144@users.noreply.github.com> Date: Fri, 18 Dec 2020 20:18:48 +0100 Subject: [PATCH 3/5] Update README.rst --- README.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 65722e3..c30655e 100644 --- a/README.rst +++ b/README.rst @@ -44,10 +44,8 @@ id of latest message in inbox: #otherwise, the email body will be None. email = session.get_email(guid) - #print some properties of the Mail object - print email.guid, email.sender, email.subject, email.body, email.read - - + #print every property of the Mail object + print email.guid, email.sender, email.subject, email.excerpt, email.datetime, email.body, email.read Example CLI Usage From 71fd4c41f7697c6d551d71a6528128986bab088e Mon Sep 17 00:00:00 2001 From: Gecko144 <74276056+Gecko144@users.noreply.github.com> Date: Fri, 18 Dec 2020 20:32:47 +0100 Subject: [PATCH 4/5] README.srt: added running client example added example of running client with continuous updates --- README.rst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.rst b/README.rst index c30655e..1627121 100644 --- a/README.rst +++ b/README.rst @@ -46,6 +46,35 @@ id of latest message in inbox: #print every property of the Mail object print email.guid, email.sender, email.subject, email.excerpt, email.datetime, email.body, email.read + +Create session, keep it running and print every new received email: + +.. code-block:: python + + from guerrillamail import GuerrillaMailSession + from time import sleep + + session = GuerrillaMailSession() + + read_number = 0 #number of read emails + read_guids = [] #guids of read emails + + while True: #keep the session running + inbox = session.get_email_list() + + if len(inbox) > read_number #check for unread emails: + for mail_object in inbox: + if mail_object.guid not in read_guids: #iterate over unread emails + full_mail = session.get_email(mail_object.guid) #full Mail object with all properties set + print full_mail.sender, full_mail.subject, full_mail.body #print mail + read_guids.append[mail_object.guid] #set mail guid as read + read_number += 1 + + sleep(10) #update every 10 seconds + + + + Example CLI Usage From 8b01b46ead64db24339be9c6e02fe3fd290ef9c9 Mon Sep 17 00:00:00 2001 From: Gecko144 <74276056+Gecko144@users.noreply.github.com> Date: Fri, 18 Dec 2020 20:45:34 +0100 Subject: [PATCH 5/5] Update README.rst fixed example syntax errors; added line about python3 --- README.rst | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 1627121..9f21a27 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ Python Guerrillamail ==================== Python Guerrillamail is a Python client API and command line interface for -interacting with a `Guerrillamail`_ temporary email server. +interacting with a `Guerrillamail`_ temporary email server. Python 3 is supported. .. image:: https://travis-ci.org/ncjones/python-guerrillamail.svg?branch=master :target: https://travis-ci.org/ncjones/python-guerrillamail @@ -53,24 +53,25 @@ Create session, keep it running and print every new received email: from guerrillamail import GuerrillaMailSession from time import sleep - + session = GuerrillaMailSession() - + read_number = 0 #number of read emails read_guids = [] #guids of read emails - + while True: #keep the session running inbox = session.get_email_list() - - if len(inbox) > read_number #check for unread emails: + + if len(inbox) > read_number: #check for unread emails: for mail_object in inbox: - if mail_object.guid not in read_guids: #iterate over unread emails + if not mail_object.guid in read_guids: #iterate over unread emails full_mail = session.get_email(mail_object.guid) #full Mail object with all properties set - print full_mail.sender, full_mail.subject, full_mail.body #print mail - read_guids.append[mail_object.guid] #set mail guid as read + print full_mail.sender, full_mail.subject, full_mail.body #print mail read_number += 1 - - sleep(10) #update every 10 seconds + read_guids.append(mail_object.guid) #set mail guid as read + + + sleep(10) #update every 10 seconds