@@ -6,24 +6,24 @@ Please see [here](https://github.com/sendgrid/python-http-client/blob/HEAD/pytho
66There are also email specific exceptions located [ here] ( ../sendgrid/helpers/mail/exceptions.py )
77
88``` python
9- import os
10- from sendgrid import SendGridAPIClient
11- from sendgrid.helpers.mail import (From, To, Subject, PlainTextContent, HtmlContent, Mail)
12- from python_http_client import exceptions
9+ import os
10+ from sendgrid import SendGridAPIClient
11+ from sendgrid.helpers.mail import (From, To, Subject, PlainTextContent, HtmlContent, Mail)
12+ from python_http_client import exceptions
1313
14- sendgrid_client = SendGridAPIClient(os.environ.get(' SENDGRID_API_KEY' ))
15- from_email = From(" help@twilio.com" )
16- to_email = To(" ethomas@twilio.com" )
17- subject = Subject(" Sending with Twilio SendGrid is Fun" )
18- plain_text_content = PlainTextContent(" and easy to do anywhere, even with Python" )
19- html_content = HtmlContent(" <strong>and easy to do anywhere, even with Python</strong>" )
20- message = Mail(from_email, to_email, subject, plain_text_content, html_content)
21- try :
22- response = sendgrid_client.send(message)
23- print (response.status_code)
24- print (response.body)
25- print (response.headers)
26- except exceptions.BadRequestsError as e:
27- print (e.body)
28- exit ()
14+ sendgrid_client = SendGridAPIClient(os.environ.get(' SENDGRID_API_KEY' ))
15+ from_email = From(" help@twilio.com" )
16+ to_email = To(" ethomas@twilio.com" )
17+ subject = Subject(" Sending with Twilio SendGrid is Fun" )
18+ plain_text_content = PlainTextContent(" and easy to do anywhere, even with Python" )
19+ html_content = HtmlContent(" <strong>and easy to do anywhere, even with Python</strong>" )
20+ message = Mail(from_email, to_email, subject, plain_text_content, html_content)
21+ try :
22+ response = sendgrid_client.send(message)
23+ print (response.status_code)
24+ print (response.body)
25+ print (response.headers)
26+ except exceptions.BadRequestsError as e:
27+ print (e.body)
28+ exit ()
2929```
0 commit comments