Skip to content

leolivier/maildropy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Python package to read emails from maildrop.cc

This package provides a very simple class MailDropReader that mimics the graphql API of maildrop.cc. You create a new reader with `MailDropReader() The methods are:

  • status(): provides the current maildrop.cc status. Returns 'operational' or an error string from the server
  • ping(string): pings the maildrop.cc server with the given string. Returns 'pong '
  • inbox(): returns all messages of your inbox Returns a list of messages with only basic fields filled. (currently returns ALL messages, the filters aren't working).
  • message(message_id): returns a full message including its body, its sender IP, ...
  • delete(message_id)__: deletes a message by its id. Returns True if ok
  • statistics(): returns maildrop.cc statistics. Returns a tuple (blocked, saved)
  • altinbox(): returns an alias for your inbox. Subsequent MailDropReaders created with this alias will return messages from the original inbox

Example:

from maildropy import MailDropReader
reader = MailDropReader("my_own-inbox")

msgs = reader.inbox()
for msg in msgs:
  print(f"subject: {msg.subject}, from: {msg.mailfrom}, date:{msg.date}")
  message = reader.message(msg.id)
  print(f"content: {message.html}, ip={message.ip}, headerfrom={message.headerfrom}"

Install

pip install maildropy

Testing the package in dev mode

To test the module: (it is recommanded to use pipenv or conda to create a virtual environment)

git clone https://github.com/leolivier/maildropy.git
cd maildropy
pip install -r requirements.txt
pip install pytest
pip install -e .  # to be able to test in dev mode
cp tests/.env.example tests/.env 
nano tests/.env # put your own setup in .env
pytest test/

The settings in tests/.env are used to send emails to maildrop.cc.It has only been tested with a gmail account and application password

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages