Answer the question
In order to leave comments, you need to log in
How to send html email to gmail in python?
I add html content.
content = Content('text/html', params.get('body'))
message.add_content(content)
Answer the question
In order to leave comments, you need to log in
The documentation for your sendgrid is lousy, but I think that you need to add a text version before the html version of the letter:
body = params.get('body')
txt_body = ... # перевести в текст, например через html2text: https://pypi.org/project/html2text/
message.add_content(txt_body , 'text/plain')
message.add_content(body, 'text/html')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question