Skip to content

Commit 30f119c

Browse files
author
Atanas Damyanliev
authored
update readme for sendapi v3.1
1 parent 5ec1e10 commit 30f119c

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

README.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,33 @@ result = mailjet.contact_getcontactslists.get(id=2)
7070
## Send an Email
7171
``` python
7272

73-
email = {
74-
'FromName': 'Mr Smith',
75-
'FromEmail': '[email protected]',
76-
'Subject': 'Test Email',
77-
'Text-Part': 'Hey there!',
78-
'Recipients': [{'Email': 'your email here'}]
73+
from mailjet_rest import Client
74+
import os
75+
api_key = os.environ['MJ_APIKEY_PUBLIC']
76+
api_secret = os.environ['MJ_APIKEY_PRIVATE']
77+
mailjet = Client(auth=(api_key, api_secret), version='v3.1')
78+
data = {
79+
'Messages': [
80+
{
81+
"From": {
82+
"Email": "[email protected]",
83+
"Name": "Mailjet Pilot"
84+
},
85+
"To": [
86+
{
87+
"Email": "[email protected]",
88+
"Name": "passenger 1"
89+
}
90+
],
91+
"Subject": "Your email flight plan!",
92+
"TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
93+
"HTMLPart": "<h3>Dear passenger 1, welcome to Mailjet!</h3><br />May the delivery force be with you!"
94+
}
95+
]
7996
}
80-
81-
mailjet.send.create(email)
97+
result = mailjet.send.create(data=data)
98+
print result.status_code
99+
print result.json()
82100

83101
```
84102

0 commit comments

Comments
 (0)