moe.mailer package¶
moe.mailer.gmailer module¶
The gmailer module contains a Mailer implementation based on Gmail.
-
class
moe.mailer.gmailer.
Gmailer
(user, destination, secret='client_secret.json', credentials='credentials.json')[source]¶ Bases:
object
Implementation of Mailer that leverages Gmail.
Capable of configuring existent gmail accounts for MOE to use. It does so through Gmail’s Label and a Filter capabilities.
Parameters: - user (str) – Email address of the user.
- destination (str) – Email address of the other MOE user.
- secret (str, optional) – Defaults to ‘client_secret.json’. File containing the OAuth 2.0 client ID of the MOE application.
- credentials (str, optional) – Defaults to ‘credentials.json’. File containing the OAuth 2.0 Google user authentification.
Raises: ValueError
– Invalid user email.ValueError
– Invalid destination email.
-
create_message
(content, subject='MOE message')[source]¶ Creates a message object for an email.
It’s receiver its the configured receiver of Mailer. It’s sender is the configured user of Mailer.
Parameters: Returns: An object containing a base64url encoded email object.
Return type:
-
delete_message
(message_id)[source]¶ Deletes a message from the inbox.
Parameters: message_id (str) – The id of the message to delete. Return type: None
-
fetch_all
()[source]¶ Fetch all the emails in MOE’s inbox.
Returns: A list with the MOE email dicts in chronological order. Return type: List[Dict]
-
fetch_unread
()[source]¶ Fetch all the emails in MOE’s inbox that are unread.
Returns: A list of MOE emails. Return type: List[Dict]
-
mark_as_read
(msg)[source]¶ Marks the email message as read from the MOE inbox in Gmail
If the message has already been read the function does not do anything.
Parameters: msg (Dict) – The MOE email to mark as read. Returns: The updated MOE email. Return type: Dict