-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(readthedocs): Update Outdated Documentation
Close #26
- Loading branch information
1 parent
f6bcdb6
commit 62c02df
Showing
13 changed files
with
772 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ Code API | |
|
||
client | ||
exceptions | ||
flags | ||
enums | ||
folder | ||
mailbox | ||
message | ||
models | ||
search |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,26 +27,46 @@ Example with Context Manager: | |
|
||
.. code-block:: python | ||
from sage_imap.services import IMAPClient, IMAPMailboxService | ||
try: | ||
with IMAPClient(host, username, password) as client: | ||
print(client.capabilities) | ||
with IMAPMailboxService(client) as mailbox: | ||
pass | ||
mailbox_service.select('INBOX') | ||
emails = mailbox_service.fetch(MessageSet('1,2,3'), MessageParts.BODY) | ||
except IMAPClientError as e: | ||
logging.critical("An error occurred: %s", e) | ||
Example without Context Manager: | ||
|
||
.. code-block:: python | ||
from sage_imap.services import IMAPClient, IMAPMailboxService | ||
try: | ||
with IMAPClient(host, username, password) as client: | ||
mailbox_service = IMAPMailboxService(client) | ||
mailbox_service.select_mailbox('INBOX') | ||
client = IMAPClient(host, username, password) | ||
mailbox_service = IMAPMailboxService(client) | ||
try: | ||
mailbox_service.select('INBOX') | ||
emails = mailbox_service.fetch(MessageSet('1,2,3'), MessageParts.BODY) | ||
mailbox_service.close_mailbox() | ||
except IMAPClientError as e: | ||
logging.critical("An error occurred during mailbox operations: %s", e) | ||
finally: | ||
try: | ||
mailbox_service.close() | ||
except Exception as e: | ||
logging.warning("Failed to close the mailbox service: %s", e) | ||
except IMAPClientError as e: | ||
logging.critical("An error occurred: %s", e) | ||
finally: | ||
try: | ||
client.logout() | ||
except Exception as e: | ||
logging.warning("Failed to close the connection: %s", e) | ||
Search Features with AND and OR Criteria | ||
---------------------------------------- | ||
|
@@ -57,6 +77,8 @@ Example of AND Criteria: | |
|
||
.. code-block:: python | ||
from sage_imap.helpers.search import IMAPSearchCriteria | ||
criteria = IMAPSearchCriteria.and_criteria( | ||
IMAPSearchCriteria.from_address("[email protected]"), | ||
IMAPSearchCriteria.subject("Meeting"), | ||
|
@@ -68,6 +90,8 @@ Example of OR Criteria: | |
|
||
.. code-block:: python | ||
from sage_imap.helpers.search import IMAPSearchCriteria | ||
criteria = IMAPSearchCriteria.or_criteria( | ||
IMAPSearchCriteria.seen(), | ||
IMAPSearchCriteria.unseen() | ||
|
@@ -83,7 +107,10 @@ Example of Fetching Message Parts: | |
|
||
.. code-block:: python | ||
emails = mailbox_service.fetch(MessageSet('1,2,3'), MessageParts.BODY) | ||
from sage_imap.helpers.enums import MessagePart | ||
from sage_imap.models import MessageSet | ||
emails = mailbox_service.fetch(MessageSet('1,2,3'), MessagePart.BODY) | ||
for email in emails: | ||
print(email.body) | ||
|
@@ -106,7 +133,7 @@ Creating a `MessageSet` with a single message ID. | |
|
||
.. code-block:: python | ||
from sage_imap.helpers.message import MessageSet | ||
from sage_imap.models import MessageSet | ||
# Single message ID | ||
message_set = MessageSet(msg_ids="123") | ||
|
@@ -120,7 +147,7 @@ Creating a `MessageSet` with a comma-separated list of message IDs. | |
|
||
.. code-block:: python | ||
from sage_imap.helpers.message import MessageSet | ||
from sage_imap.models import MessageSet | ||
# Comma-separated message IDs | ||
message_set = MessageSet(msg_ids="123,124,125") | ||
|
@@ -134,7 +161,7 @@ Creating a `MessageSet` with a range of message IDs. | |
|
||
.. code-block:: python | ||
from sage_imap.helpers.message import MessageSet | ||
from sage_imap.models import MessageSet | ||
# Range of message IDs | ||
message_set = MessageSet(msg_ids="123:125") | ||
|
@@ -148,7 +175,7 @@ Creating a `MessageSet` with a list of message IDs. | |
|
||
.. code-block:: python | ||
from sage_imap.helpers.message import MessageSet | ||
from sage_imap.models import MessageSet | ||
# List of message IDs | ||
message_set = MessageSet(msg_ids=[123, 124, 125]) | ||
|
@@ -162,7 +189,7 @@ Handling an invalid message ID. | |
|
||
.. code-block:: python | ||
from sage_imap.helpers.message import MessageSet | ||
from sage_imap.models import MessageSet | ||
try: | ||
# Invalid message ID | ||
|
@@ -178,7 +205,7 @@ Handling an empty message ID. | |
|
||
.. code-block:: python | ||
from sage_imap.helpers.message import MessageSet | ||
from sage_imap.models import MessageSet | ||
try: | ||
# Empty message ID | ||
|
Oops, something went wrong.