8000 updating Mailjet code samples for Send API v3.1 (#1071) · johnmanong/python-docs-samples@8a17bdb · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a17bdb

Browse files
Atanas DamyanlievJon Wayne Parrott
Atanas Damyanliev
authored and
Jon Wayne Parrott
committed
updating Mailjet code samples for Send API v3.1 (GoogleCloudPlatform#1071)
* Update main.py updating main.py to match configuration for Mailjet Send API v3.1 * update readme.md reference in readme.md is to Mailgun instead of Mailjet * update main.py updating main.py to match configuration for Mailjet Send API v3.1 * update main.py fixing indentation * update main.py fixing indentation * fixing indentation fixing indentation to pass lint * fixing indentation fixing indentation issues to pass lint * Fix indentation * Fix indentation
1 parent e0f957c commit 8a17bdb

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

appengine/flexible/mailjet/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Python Mailjet email sample for Google App Engine Flexible
22

3-
This sample demonstrates how to use [Mailjet](https://www.mailgun.com) on [Google App Engine Flexible](https://cloud.google.com/appengine/docs/flexible/).
3+
This sample demonstrates how to use [Mailjet](https://www.mailjet.com) on [Google App Engine Flexible](https://cloud.google.com/appengine/docs/flexible/).
44

55
## Setup
66

@@ -17,7 +17,7 @@ Refer to the [top-level README](../README.md) for instructions on running and de
1717
You can run the application locally and send emails from your local machine. You
1818
will need to set environment variables before starting your application:
1919

20-
$ export MAILGUN_API_KEY=[your-mailgun-api-key]
21-
$ export MAILGUN_API_SECRET=[your-mailgun-secret]
22-
$ export MAILGUN_SENDER=[your-sender-address]
20+
$ export MAILJET_API_KEY=[your-mailjet-api-key]
21+
$ export MAILJET_API_SECRET=[your-mailjet-secret]
22+
$ export MAILJET_SENDER=[your-sender-address]
2323
$ python main.py

appengine/flexible/mailjet/main.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,21 @@
3131
# [START send_message]
3232
def send_message(to):
3333
client = mailjet_rest.Client(
34-
auth=(MAILJET_API_KEY, MAILJET_API_SECRET))
34+
auth=(MAILJET_API_KEY, MAILJET_API_SECRET), version='v3.1')
3535

3636
data = {
37-
'FromEmail': MAILJET_SENDER,
38-
'FromName': 'App Engine Flex Mailjet Sample',
39-
'Subject': 'Example email.',
40-
'Text-part': 'This is an example email.',
41-
'Html-part': 'This is an <i>example</i> email.',
42-
'Recipients': [{'Email': to}]
37+
'Messages': [{
38+
"From": {
39+
"Email": MAILJET_SENDER,
40+
"Name": 'App Engine Flex Mailjet Sample'
41+
},
42+
"To": [{
43+
"Email": to
44+
}],
45+
"Subject": 'Example email.',
46+
"TextPart": 'This is an example email.',
47+
"HTMLPart": 'This is an <i>example</i> email.'
48+
}]
4349
}
4450

4551
result = client.send.create(data=data)

appengine/standard/mailjet/main.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,21 @@
3636
# [START send_message]
3737
def send_message(to):
3838
client = mailjet_rest.Client(
39-
auth=(MAILJET_API_KEY, MAILJET_API_SECRET))
39+
auth=(MAILJET_API_KEY, MAILJET_API_SECRET), version='v3.1')
4040

4141
data = {
42-
'FromEmail': MAILJET_SENDER,
43-
'FromName': 'App Engine Flex Mailjet Sample',
44-
'Subject': 'Example email.',
45-
'Text-part': 'This is an example email.',
46-
'Html-part': 'This is an <i>example</i> email.',
47-
'Recipients': [{'Email': to}]
42+
'Messages': [{
43+
"From": {
44+
"Email": MAILJET_SENDER,
45+
"Name": 'App Engine Standard Mailjet Sample'
46+
},
47+
"To": [{
48+
"Email": to
49+
}],
50+
"Subject": 'Example email.',
51+
"TextPart": 'This is an example email.',
52+
"HTMLPart": 'This is an <i>example</i> email.'
53+
}]
4854
}
4955

5056
result = client.send.create(data=data)

0 commit comments

Comments
 (0)
0