13

I have been using the guides for the gmail api to create drafts. The following code has been working well.

def create_message(sender, to, subject, message_text):

  message = MIMEText(message_text)
  message['to'] = to
  message['from'] = sender
  message['subject'] = subject
  return {'raw': base64.urlsafe_b64encode(message.as_string())}

My question is, how do I add multiple recipients? The API guides seem to not mention anything of the sort.

James L
  • 350
  • 1
  • 3
  • 13

1 Answers1

22

MIMEText expects a string of comma separated recipients:

message['to'] = 'me@gmail.com, you@gmail.com'
Nils Werner
  • 34,832
  • 7
  • 76
  • 98