Coder Social home page Coder Social logo

devmail's Introduction

DeveloperMail python wrapper based on official documentation https://www.developermail.com/api/v1/

Install

pip install devmail

Usage

Create mailbox

>>> from devmail import DevMail
>>> mailbox = DevMail()
>>> mailbox.create()
{'username': 'z-pypjq7', 'token': 'AD5002F7F660C2D61A91B5F1DCABF0819E2F79D4'}

Create new token

>>> mailbox.newtoken()
{'username': 'z-pypjq7', 'token': 'FA3CEC39B32E03DD6E5011FE4B1A4FCA7EC9C28A'}

Send a message

>>> mail = {'subject': 'Hello!', 'body': 'There!', 'isHtml': False}
>>> mailbox.sendmail(mail)
{'success': True, 'errors': None, 'result': True}

Send another message

>>> mail = {'subject': 'Hello!', 'body': 'Again!', 'isHtml': False}
>>> mailbox.sendmail(mail)
{'success': True, 'errors': None, 'result': True}

Get message IDs

>>> mailbox.getmailids()
['637578381535439379', '637578381749371824']

The email id is a unix timestamp.

Get messages from list of id

>>> mails = mailbox.getmails(['637578381535439379', '637578381749371824'], raw=False)
>>> len(mails)
2
>>> mails[0]
{'key': '637578381535439379', 'value': {'MIME-Version': '1.0', 'From': '[email protected]', 'To': '[email protected]', 'Date': '28 May 2021 22:35:53 +0000', 'Subject': 'Hello!', 'Content-Type': 'text/plain; charset=us-ascii', 'Content-Transfer-Encoding': 'quoted-printable'}}

It will return list of {'key': mail id, 'value': parsed mail content}. If mailids list is not supplied, it will return all emails available after the last call to mailbox.getmailids(). This method parses raw email content by default. To disable this behaviour, set raw=True.

Get a single message

>>> mail = mailbox.getmail('637578381749371824')
>>> mail
{'MIME-Version': '1.0', 'From': '[email protected]', 'To': '[email protected]', 'Date': '28 May 2021 22:36:14 +0000', 'Subject': 'Hello!', 'Content-Type': 'text/plain; charset=us-ascii', 'Content-Transfer-Encoding': 'quoted-printable'}

Delete a message

>>> mailbox.delmail('637578381535439379')
{'success': True, 'errors': None, 'result': True}
>>> mailbox.getmail('637578381535439379', raw=True) # return None
>>> mailbox.getmailids()
['637578381749371824']

Destroy mailbox

>>> mailbox.destroy()
{'success': True, 'errors': None, 'result': True}

TBD:

  1. Empty mailbox
  2. Convert timestamp to Date Time
  3. Save credentials
  4. Refactor code

devmail's People

Contributors

faruqsandi avatar nikhilweee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.