Skip to content
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

Allow the use of Mailgun's EU region #426

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions source/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export const schema = {
},
},
email: {
apiHost: {
doc: 'The Mailgun host to use. Note that if you are using the EU region the host should be set to `api.eu.mailgun.net`. Will be overridden by a `notifications.apiHost` parameter in the site config, if one is set.',
format: String,
default: 'api.mailgun.net',
env: 'EMAIL_API_HOST'
},
apiKey: {
doc:
'Mailgun API key to be used for email notifications. Will be overridden by a `notifications.apiKey` parameter in the site config, if one is set.',
Expand Down
2 changes: 2 additions & 0 deletions source/lib/Staticman.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,9 @@ export default class Staticman {
if (!this.siteConfig.get('notifications.enabled')) return null;

// Initialise Mailgun
const mailgunHost = this.siteConfig.get('notifications.apiHost') || config.get('email.apiHost')
const mailgun = Mailgun({
...(mailgunHost && { host: mailgunHost }),
apiKey: this.siteConfig.get('notifications.apiKey') || config.get('email.apiKey'),
domain: this.siteConfig.get('notifications.domain') || config.get('email.domain'),
});
Expand Down
5 changes: 5 additions & 0 deletions source/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ export const schema = {
format: Boolean,
default: false,
},
apiHost: {
doc: 'Mailgun API host. Note that if you are using the EU region the host should be set to `api.eu.mailgun.net`.',
format: String,
default: 'api.mailgun.net'
},
apiKey: {
doc: 'Mailgun API key',
format: 'EncryptedString',
Expand Down
3 changes: 3 additions & 0 deletions staticman.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ comments:
# Enable notifications
#enabled: true

# Mailgun API host name. If in EU Region, use 'api.eu.mailgun.net'
#apiHost: api.mailgun.net

# (!) ENCRYPTED
#
# Mailgun API key
Expand Down