Skip to content

Instantly share code, notes, and snippets.

@theand
Created August 9, 2017 02:24
Show Gist options
  • Save theand/4eebfee874350c58a4b0eaa570eb5073 to your computer and use it in GitHub Desktop.
Save theand/4eebfee874350c58a4b0eaa570eb5073 to your computer and use it in GitHub Desktop.
email.py
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