The msg["To"]
parameter normally takes addresses separated by comma and a space so the following should be what you need:
email_string = 'XXXXXXXX@gmail.com,XXXXXXXX@gmail.com,XXXXXXXX@gmail.com'
msg["To"] = ', '.join(email_string.split(',')
This would pass the following single string:
XXXXXXXX@gmail.com, XXXXXXXX@gmail.com, XXXXXXXX@gmail.com
or alternatively, you could use a replace to add a space:
msg["To"] = email_string.replace(',', ', ')
If you want your string to have quotes around each email address:
email_string = "'{}'".format("','".join(email_string.split(',')))
Giving you a string looking like:
'XXXXXXXX@gmail.com','XXXXXXXX@gmail.com','XXXXXXXX@gmail.com'