Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding multiple recipients using google api in python?

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.

like image 931
James L Avatar asked Oct 25 '16 14:10

James L


1 Answers

MIMEText expects a string of comma separated recipients:

message['to'] = '[email protected], [email protected]'
like image 149
Nils Werner Avatar answered Sep 20 '22 05:09

Nils Werner