https://github.com/coreygirard/pmail
Crazy simple Gmail fetching via username and password. Bells and whistles not included.
https://github.com/coreygirard/pmail
active
Last synced: about 2 months ago
JSON representation
Crazy simple Gmail fetching via username and password. Bells and whistles not included.
- Host: GitHub
- URL: https://github.com/coreygirard/pmail
- Owner: coreygirard
- Created: 2017-11-27T21:14:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-12-05T18:31:39.000Z (5 months ago)
- Last Synced: 2025-12-14T03:17:35.443Z (5 months ago)
- Topics: active
- Language: Python
- Homepage:
- Size: 48.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pmail
[](https://travis-ci.org/coreygirard/pmail)
[](https://github.com/ambv/black)
**THIS IS ALL INACCURATE FOR THE MOMENT**
### Basic usage
```python
gmail = Gmail('tokens.json')
for folder in gmail.get_folders():
print('\n\nFolder: ' + folder.name)
for message in folder.get_emails():
print(message.get_subject())
```
```
Folder: Important
Top 10 sweaters made from dryer lint
Exclusive adventures to watch paint dry! Act now!
Folder: Unimportant
You are two centuries behind on your rent
One trick to tell if your house is on fire
Is your car cheating on you?
```
#### Explanation
```python
gmail = Gmail(filepath)
```
`filepath` is the path to a JSON file formatted with your Gmail username and password:
```json
{ "username": "notmyemail@gmail.com", "password": "notmypassword" }
```
`Gmail()` returns an object that can be used to fetch your Gmail folders. `.get_folders()` returns a list of `Folder` objects:
```python
for folder in gmail.get_folders()
```
The `.name` property of a Folder object gives the folder label. To get all emails in a folder, use `.get_emails()`:
```python
for message in folder.get_emails()
```
`Email` objects provide various methods to return the email components:
```
message.get_to()
message.get_from()
message.get_subject()
```
More coming soon!