Coder Social home page Coder Social logo

emailclient's Introduction

Usage

This library is really easy to use:

from supermail import EmailClient

# define email client
gmail = EmailClient("[email protected]", "your_password")

# get all messages
messages = gmail.read() # if you need only unread, set parameter filter=['UNSEEN']

# for each message
for msg in messages:
	# get message info
	print(msg.subject())
	print(msg.message())
	print(msg.sender())
	# get attachments
	attachments = msg.attachments('./temp') # returns a list of filenames saved in specified dir

# send a message with attachments
gmail.send('[email protected]', 'Nice subject', 'Nice message', \
	cc='[email protected]',
	attachments=['/path/to/pdf.pdf', '/path/to/image.png'])

Note

In order to use GMail, you need to log into your security page and:

  1. enable two-step verification
  2. right below, it will appear an option called App Password. Create a new one that you will be able to use with supermail.

Other email? No problem!

You can specify custom imap and smtp addresses and ports:

email_address = "[email protected]"
email_pwd = "your_password"
imap_server = "imap.gmail.com"
imap_port   = 993
smtp_server='smtp.gmail.com'
smtp_port=587

# define email client
gmail = EmailClient(email_address, email_pwd, imap_server, imap_port, smtp_server, smtp_port)

Install

You can install supermail from PyPI:

pip install supermail

or from the github page:

pip install git+https://github.com/dros1986/EmailClient.git

emailclient's People

Contributors

celuigi avatar dros1986 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

celuigi max0913

emailclient's Issues

Cannot grab x number of emails

Hi! Less of an issue, more a suggestion. I feel it would be a great addition to make some way to pull only a certain number of emails from the inbox, as opposed to all of them. When your inbox is full, it takes quite a while for it to gather all the content.

As a solution, I feel it would be best to make gmail.read() iterable. e.g. gmail.read()[2] would get you the latest 2 emails in your inbox, and so on.

If there is a way to do this, then ignore me or add it to the documentation (I've put pushes on my feed). Overall though, very useful package; 10/10 ๐Ÿ‘ :)

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.