from email.message import EmailMessage
msg = EmailMessage()
msg['From'] = 'Nik@example.com'
msg['To'] = 'Nathaniel@example.com'
msg['Subject'] = 'Example of a message in Spanish and English'
msg['Content-Disposition'] = 'inline' # redundant?
msg.set_content = """\
This is a message in multiple languages. It says the
same thing in each language. If you can read it in one language,
you can ignore the other translations. The other translations may be
presented as attachments or grouped together.
Este es un mensaje en varios idiomas. Dice lo mismo en
cada idioma. Si puede leerlo en un idioma, puede ignorar las otras
traducciones. Las otras traducciones pueden presentarse como archivos
adjuntos o agrupados.
"""
suben = EmailMessage()
suben['Content-Language'] = 'en-GB'
suben['Content-Translation-Type'] = 'original'
#suben['Content-Disposition'] = 'inline' # redundant?
suben['Subject'] = 'Example of a message in Spanish and English'
suben.set_content("Hello, this message content is provided in your language.")
suben.add_header('Content-Language', 'en-GB')
suben.add_header('Content-Disposition', 'inline')
subes = EmailMessage()
subes['Content-Language'] = 'es-ES'
subes['Content-Translation-Type'] = 'human'
subes['Content-Disposition'] = 'inline' # redundant?
subes['Subject'] = 'Ejemplo práctico de mensaje en español e inglés'
subes.set_content("Hola, el contenido de este mensaje esta disponible en su idioma.")
subes.add_header('Content-Language', 'es-ES')
subes.add_header('Content-Disposition', 'inline')
msg.add_attachment(suben)
msg.add_attachment(subes)
msg.replace_header('Content-type', 'multipart/multilingual')
print(msg.as_string())