|
1 | 1 | import sendgrid |
2 | | -from sendgrid.helpers.mail import Email, Content, Mail |
| 2 | +from sendgrid.helpers.mail import Mail |
3 | 3 |
|
4 | | -sg = sendgrid.SendGridAPIClient(apikey='<apikey>') |
| 4 | +sg = sendgrid.SendGridAPIClient(api_key="MY_API_KEY") |
5 | 5 |
|
6 | | -from_email = Email("test@example.com") |
| 6 | +from_email = "test@example.com" |
7 | 7 | subject = "Winter is coming" |
8 | | -to_email = Email("<youremail>@<domain>") |
9 | | -content = Content("text/plain", "So... put on a jumper!") |
| 8 | +to_email = "<youremail>@<domain>" |
| 9 | +content = "So... put on a jumper!" |
10 | 10 |
|
11 | | -mail = Mail(from_email, subject, to_email, content) |
| 11 | +mail = Mail(from_email, to_email, subject, content) |
12 | 12 |
|
13 | | -response = sg.client.mail.send.post(request_body=mail.get()) |
| 13 | +response = sg.send(mail) |
14 | 14 |
|
15 | 15 | print(response.status_code) |
16 | 16 | print(response.body) |
|
0 commit comments