DeveloperMail python wrapper based on official documentation https://www.developermail.com/api/v1/
pip install devmail
>>> from devmail import DevMail
>>> mailbox = DevMail()
>>> mailbox.create()
{'username': 'z-pypjq7', 'token': 'AD5002F7F660C2D61A91B5F1DCABF0819E2F79D4'}
>>> mailbox.newtoken()
{'username': 'z-pypjq7', 'token': 'FA3CEC39B32E03DD6E5011FE4B1A4FCA7EC9C28A'}
>>> mail = {'subject': 'Hello!', 'body': 'There!', 'isHtml': False}
>>> mailbox.sendmail(mail)
{'success': True, 'errors': None, 'result': True}
>>> mail = {'subject': 'Hello!', 'body': 'Again!', 'isHtml': False}
>>> mailbox.sendmail(mail)
{'success': True, 'errors': None, 'result': True}
>>> mailbox.getmailids()
['637578381535439379', '637578381749371824']
The email id is a unix timestamp.
>>> 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
.
>>> 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'}
>>> mailbox.delmail('637578381535439379')
{'success': True, 'errors': None, 'result': True}
>>> mailbox.getmail('637578381535439379', raw=True) # return None
>>> mailbox.getmailids()
['637578381749371824']
>>> mailbox.destroy()
{'success': True, 'errors': None, 'result': True}
TBD:
- Empty mailbox
- Convert timestamp to Date Time
- Save credentials
- Refactor code