diff --git a/README.md b/README.md index 06d70b17..5ca3811e 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Staticwoman is a fork of [Staticman](https://github.com/eduardoboucas/staticman) - [Customizing the size of generated comment IDs](https://github.com/hispanic/staticwoman/pull/9) - [Bypassing Akismet spam-checking when testing](https://github.com/hispanic/staticwoman/pull/10) - [Support for a development lifecycle that progresses through multiple environments (e.g., dev, staging, prod)](https://github.com/hispanic/staticwoman/pull/11) +- [Configuring the Mailgun region/host](https://github.com/hispanic/staticwoman/pull/12) I expect that the original Staticman project will include some version of the above functionality sooner or later. Until then, here 'tis. I haven't made any effort to document this new functionality beyond the comments found in the above-referenced pull requests. If you have interest in making use of any of these features and you'd like to see said documentation created, please open an issue and I'll see what I can do. diff --git a/config.js b/config.js index 0206ea05..1fd5b420 100644 --- a/config.js +++ b/config.js @@ -50,6 +50,12 @@ const schema = { env: 'BRANCH' }, email: { + apiHost: { + doc: 'Mailgun API host/region to be used for email notifications. Will be overridden by a `notifications.apiHost` parameter in the site/repo 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/repo config, if one is set.', format: String, diff --git a/lib/Staticman.js b/lib/Staticman.js index c799c9e9..b99fd199 100644 --- a/lib/Staticman.js +++ b/lib/Staticman.js @@ -390,6 +390,7 @@ class Staticman { // Initialise Mailgun const mailgun = Mailgun({ apiKey: this.siteConfig.get('notifications.apiKey') || config.get('email.apiKey'), + host: this.siteConfig.get('notifications.apiHost') || config.get('email.apiHost'), domain: this.siteConfig.get('notifications.domain') || config.get('email.domain') }) diff --git a/siteConfig.js b/siteConfig.js index f98d4d56..74cee14c 100644 --- a/siteConfig.js +++ b/siteConfig.js @@ -157,6 +157,11 @@ const schema = { format: ['none', 'single', 'double'], default: 'none' }, + apiHost: { + doc: 'Mailgun API host/region', + format: String, + default: '' + }, apiKey: { doc: 'Mailgun API key', format: 'EncryptedString', diff --git a/staticman.sample.yml b/staticman.sample.yml index ec5e58b7..b861b598 100644 --- a/staticman.sample.yml +++ b/staticman.sample.yml @@ -57,6 +57,9 @@ comments: # Mailgun API key #apiKey: "1q2w3e4r" + # Mailgun API host/region. If in EU region, use 'api.eu.mailgun.net'. + #apiHost: "api.mailgun.net" + # (!) ENCRYPTED # # Mailgun domain (encrypted)