Skip to main content

A Python interface to interact with gmail.

Project description

A Python interface for sending, reading, and deleting emails

Functions:

  • readmail - read an email
  • sendmail - send an email
  • sendmailobj - send an EmailMessage object with changable specs.
  • forward - forward an EmailMessage object with changable specs.


Usage:

    >>> import emailpy
    >>> sent = emailpy.sendmail("fromemail@gmail.com", "fromemail_password",
                    toemails = ["toemail1@gmail.com", "toemail2@gmail.com")
                    subject = 'Subject', body = 'Body',
                    attachments = ['file.txt', 'picture.png'])
    >>> # send an email from
    >>> # "fromemail@gmail.com" and password "fromemail_password" to
    >>> # "toemail1@gmail.com" and "toemail2@gmail.com" with subject
    >>> # "Subject" and body "Body" and retreive the message into the variable
    >>> # "sent". 
    >>> data = emailpy.readmail("toemail1@gmail.com", "toemail1_password") # read
    >>> # email "toemail1@gmail.com" with password "toemail1_password"
    >>> data = data[0] # get first email from EmailMessageList object
    >>> data.body # "Body"
    >>> data.subject # "Subject"
    >>> data.html # "Body"
    >>> data.sender # "fromemail@gmail.com"
    >>> data.recvers # ["toemail1@gmail.com", "toemail2@gmail.com"]
    >>> data.show() # 
    >>> data.attachments # >> # "picture.png"]>
    >>> data.attachments.download() # save attached files to computer
    >>> data.attachments.show() # show attached files
    >>> # WARNING: when using data.attachments.show(), you must first call
    >>> # data.attachments.download()
    >>> data.is_attachment # True
    >>> data.delete() # delete email
    >>> emailpy.sendmailobj(sent, attachments = ['file2.txt']) # send the sent
    >>> # variable as an email, but replacing the attachments list with
    >>> # ['file2.txt'].
    >>> emailpy.forward(data, 'forwardtome@yahoo.com', body = 'hi') # forward
    >>> # the read email to "forwardtome@yahoo.com", but replacing the body
    >>> # with "hi". NOTE that this only works on read emails. So, you cannot
    >>> # use the emailpy.forward() method on sent or forwarded emails. 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

emailpy-0.1.6-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page