Skip to content

solanav/red-box

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Red Box: Advanced Email Box Reader

Next generation email box reader/manager


Pypi version Documentation Status PyPI pyversions

What is it?

Red Box is an advanced email box reader library. It is a sister library for Red Mail, advanced email sender. It makes managing your email box in Python very easy.

Core features:

  • Easy email searching
  • Intuitive message manipulation
  • Intuitive email box manipulation

Install it from PyPI:

pip install redbox2

Why Red Box?

Imaplib from standard library is complex to use and unintuitive. Red Box makes reading email boxes easy.

With Red Box, it is simple as this:

from redbox import EmailBox

# Create an email box instance
box = EmailBox(host="localhost", port=0)

# Select an email folder
inbox = box['INBOX']

# Get emails
emails = inbox.search(
    from_="[email protected]",
    subject="Red Box released",
    unseen=True
)

More Examples

There is also a query language for arbitrary search queries:

from redbox.query import FROM, UNSEEN, FLAGGED

emails = inbox.search(
    FROM('[email protected]') & (UNSEEN | FLAGGED)
)

Red Box also makes reading different parts of the email messages easy:

# Get one email
email = emails[0]

# String representation of the message
print(email.content)

# Email contents
print(email.text_body)
print(email.html_body)

# Email headers
print(email.from_)
print(email.to)
print(email.date)

Here is a complete example:

from redbox import EmailBox

box = EmailBox(host="localhost", port=0)
inbox = box['INBOX']

for msg in inbox.search(subject="example 2", unseen=True):

    # Process the message
    print(msg.subject)
    print(msg.text_body)

    # Set the message as read/seen
    msg.read()

See more from the documentation.

If the library helped you save time, consider buying a coffee for the maintainer ☕.

Author

About

Fork of the next generation email box manager

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Python 100.0%