Skip to content

updating Mailjet code samples for Send API v3.1 #1071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions appengine/flexible/mailjet/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Python Mailjet email sample for Google App Engine Flexible

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

## Setup

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

$ export MAILGUN_API_KEY=[your-mailgun-api-key]
$ export MAILGUN_API_SECRET=[your-mailgun-secret]
$ export MAILGUN_SENDER=[your-sender-address]
$ export MAILJET_API_KEY=[your-mailjet-api-key]
$ export MAILJET_API_SECRET=[your-mailjet-secret]
$ export MAILJET_SENDER=[your-sender-address]
$ python main.py
20 changes: 13 additions & 7 deletions appengine/flexible/mailjet/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,21 @@
# [START send_message]
def send_message(to):
client = mailjet_rest.Client(
auth=(MAILJET_API_KEY, MAILJET_API_SECRET))
auth=(MAILJET_API_KEY, MAILJET_API_SECRET), version='v3.1')

data = {
'FromEmail': MAILJET_SENDER,
'FromName': 'App Engine Flex Mailjet Sample',
'Subject': 'Example email.',
'Text-part': 'This is an example email.',
'Html-part': 'This is an <i>example</i> email.',
'Recipients': [{'Email': to}]
'Messages': [{
"From": {
"Email": MAILJET_SENDER,
"Name": 'App Engine Flex Mailjet Sample'
},
"To": [{
"Email": to
}],
"Subject": 'Example email.',
"TextPart": 'This is an example email.',
"HTMLPart": 'This is an <i>example</i> email.'
}]
}

result = client.send.create(data=data)
Expand Down
20 changes: 13 additions & 7 deletions appengine/standard/mailjet/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,21 @@
# [START send_message]
def send_message(to):
client = mailjet_rest.Client(
auth=(MAILJET_API_KEY, MAILJET_API_SECRET))
auth=(MAILJET_API_KEY, MAILJET_API_SECRET), version='v3.1')

data = {
'FromEmail': MAILJET_SENDER,
'FromName': 'App Engine Flex Mailjet Sample',
'Subject': 'Example email.',
'Text-part': 'This is an example email.',
'Html-part': 'This is an <i>example</i> email.',
'Recipients': [{'Email': to}]
'Messages': [{
"From": {
"Email": MAILJET_SENDER,
"Name": 'App Engine Standard Mailjet Sample'
},
"To": [{
"Email": to
}],
"Subject": 'Example email.',
"TextPart": 'This is an example email.',
"HTMLPart": 'This is an <i>example</i> email.'
}]
}

result = client.send.create(data=data)
Expand Down