module automation_students.mail_helper

Short summary

module ensae_teaching_cs.automation_students.mail_helper

Some automation helpers to grab mails from student about project.

source on GitHub

Functions

function truncated documentation
extract_students_mail_and_name_from_gmail Extracts mails and names from a mail box.
grab_addresses Looks for some emails in a mail box from specific emails or sent to specific emails.

Documentation

Some automation helpers to grab mails from student about project.

source on GitHub

ensae_teaching_cs.automation_students.mail_helper.extract_students_mail_and_name_from_gmail(user=None, pwd=None, server='imap.gmail.com', mailfolder=['ensae/actuariat'], date='1-Jan-2016', fLOG=<function noLOG>)[source]

Extracts mails and names from a mail box.

Paramètres:
  • user – user of the gmail inbox
  • pwd – password of the gmail inbox
  • server – gmail server, it should be "imap.gmail.com", it works with others mail servers using the IMAP protocol
  • mailfolder – folder in your inbox to look into, there can be several
  • date – when to start looking (do not change the format, look at the default value)
  • fLOG – logging function
Renvoie:

list of dictionary [{"name": ..., "mail": ...}]

source on GitHub

ensae_teaching_cs.automation_students.mail_helper.grab_addresses(mailbox, subfolder, date, no_domain=False, max_dest=5, names=False, fLOG=<function noLOG>)[source]

Looks for some emails in a mail box from specific emails or sent to specific emails.

Paramètres:
  • mailbox – MailBoxImap object (we assume you are logged in)
  • date – date (grab emails since …, example 1-Oct-2014)
  • subfolder – folder of the mailbox to look into
  • no_domain – remove domain when searching for emails
  • max_dest – number of receivers to have a valid mail
  • names – if true, return suggestions for names for each mail
  • fLOG – logging function
Renvoie:

list of emails or tuple(list of emails, dictionary(email: name)) if names is True

Collect email addresses from mails in an inbox folder)

from ensae_teaching_cs.automation_students import grab_addresses
from pymmails import MailBoxImap

user = "xavier.dupre"
pwd = "***"
server = "imap.gmail.com"
mailfolder = ["ensae/ENSAE_2016", "ensae/ensae_interro_2015"]
date = "1-Dec-2015"

box = MailBoxImap(user, pwd, server, ssl=True, fLOG=fLOG)
box.login()
emails = grab_addresses(box, mailfolder, date, fLOG=fLOG)
box.logout()

source on GitHub