Created
August 9, 2017 02:24
-
-
Save theand/4eebfee874350c58a4b0eaa570eb5073 to your computer and use it in GitHub Desktop.
email.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from email.mime.text import MIMEText | |
def CreateMessage(sender, to, subject, message_text): | |
"""Create a message for an email. | |
Args: | |
sender: Email address of the sender. | |
to: Email address of the receiver. | |
subject: The subject of the email message. | |
message_text: The text of the email message. | |
Returns: | |
An object containing a base64url encoded email object. | |
""" | |
message = MIMEText(message_text) | |
message['to'] = to | |
message['from'] = sender | |
message['subject'] = subject | |
return {'raw': base64.urlsafe_b64encode(message.as_string())} | |
CreateMessage('sender@gmail.com', 'receiver@naver.com', 'hello', 'world') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment