Updated installation script
This commit is contained in:
parent
63f20a199a
commit
d651cca039
5 changed files with 104 additions and 3 deletions
|
@ -41,6 +41,11 @@ module.exports.sendMail = (mail, template, callback) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mail.headers) {
|
||||||
|
mail.headers = {};
|
||||||
|
}
|
||||||
|
mail.headers['X-Sending-Zone'] = 'transactional';
|
||||||
|
|
||||||
getTemplate(template.html, (err, htmlRenderer) => {
|
getTemplate(template.html, (err, htmlRenderer) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|
|
@ -13,7 +13,7 @@ let upload = multer();
|
||||||
|
|
||||||
let settings = require('../lib/models/settings');
|
let settings = require('../lib/models/settings');
|
||||||
|
|
||||||
let allowedKeys = ['service_url', 'smtp_hostname', 'smtp_port', 'smtp_encryption', 'smtp_disable_auth', 'smtp_user', 'smtp_pass', 'admin_email', 'smtp_log', 'smtp_max_connections', 'smtp_max_messages', 'smtp_self_signed', 'default_from', 'default_address', 'default_subject', 'default_homepage', 'default_postaddress', 'default_sender', 'verp_hostname', 'verp_use', 'disable_wysiwyg', 'pgp_private_key', 'pgp_passphrase', 'ua_code', 'shoutout', 'disable_confirmations', 'smtp_throttling'];
|
let allowedKeys = ['service_url', 'smtp_hostname', 'smtp_port', 'smtp_encryption', 'smtp_disable_auth', 'smtp_user', 'smtp_pass', 'admin_email', 'smtp_log', 'smtp_max_connections', 'smtp_max_messages', 'smtp_self_signed', 'default_from', 'default_address', 'default_subject', 'default_homepage', 'default_postaddress', 'default_sender', 'verp_hostname', 'verp_use', 'disable_wysiwyg', 'pgp_private_key', 'pgp_passphrase', 'ua_code', 'shoutout', 'disable_confirmations', 'smtp_throttling', 'dkim_api_key', 'dkim_private_key', 'dkim_selector', 'dkim_domain'];
|
||||||
|
|
||||||
router.all('/*', (req, res, next) => {
|
router.all('/*', (req, res, next) => {
|
||||||
if (!req.user) {
|
if (!req.user) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ let express = require('express');
|
||||||
let router = new express.Router();
|
let router = new express.Router();
|
||||||
let request = require('request');
|
let request = require('request');
|
||||||
let campaigns = require('../lib/models/campaigns');
|
let campaigns = require('../lib/models/campaigns');
|
||||||
|
let settings = require('../lib/models/settings');
|
||||||
let log = require('npmlog');
|
let log = require('npmlog');
|
||||||
let multer = require('multer');
|
let multer = require('multer');
|
||||||
let uploads = multer();
|
let uploads = multer();
|
||||||
|
@ -286,4 +287,44 @@ router.post('/zone-mta', (req, res, next) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/zone-mta/sender-config', (req, res) => {
|
||||||
|
if (!req.query.api_token) {
|
||||||
|
return res.json({
|
||||||
|
error: 'api_token value not set'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
settings.list(['dkim_api_key', 'dkim_private_key', 'dkim_selector', 'dkim_domain'], (err, configItems) => {
|
||||||
|
if (err) {
|
||||||
|
return res.json({
|
||||||
|
error: err.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configItems.dkimApiKey !== req.query.api_token) {
|
||||||
|
return res.json({
|
||||||
|
error: 'invalid api_token value'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
configItems.dkimSelector = (configItems.dkimSelector || '').trim();
|
||||||
|
configItems.dkimPrivateKey = (configItems.dkimPrivateKey || '').trim();
|
||||||
|
|
||||||
|
if (!configItems.dkimSelector || !configItems.dkimPrivateKey) {
|
||||||
|
// empty response
|
||||||
|
return res.json({});
|
||||||
|
}
|
||||||
|
|
||||||
|
let from = (req.body.from || '').trim();
|
||||||
|
let domain = from.split('@').pop().toLowerCase().trim();
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
keys: {
|
||||||
|
domainName: configItems.dkimDomain || domain,
|
||||||
|
keySelector: configItems.dkimSelector,
|
||||||
|
privateKey: configItems.dkimPrivateKey
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
|
@ -26,6 +26,7 @@ fi
|
||||||
HOSTNAME="${HOSTNAME:-`hostname`}"
|
HOSTNAME="${HOSTNAME:-`hostname`}"
|
||||||
|
|
||||||
MYSQL_PASSWORD=`pwgen -1`
|
MYSQL_PASSWORD=`pwgen -1`
|
||||||
|
DKIM_API_KEY=`pwgen -1`
|
||||||
|
|
||||||
# Setup MySQL user for Mailtrain
|
# Setup MySQL user for Mailtrain
|
||||||
mysql -u root -e "CREATE USER 'mailtrain'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';"
|
mysql -u root -e "CREATE USER 'mailtrain'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';"
|
||||||
|
@ -57,6 +58,7 @@ INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_encryption','NONE')
|
||||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_port','587') ON DUPLICATE KEY UPDATE \`value\`='587';
|
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_port','587') ON DUPLICATE KEY UPDATE \`value\`='587';
|
||||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('default_homepage','http://$HOSTNAME/') ON DUPLICATE KEY UPDATE \`value\`='http://$HOSTNAME/';
|
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('default_homepage','http://$HOSTNAME/') ON DUPLICATE KEY UPDATE \`value\`='http://$HOSTNAME/';
|
||||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('service_url','http://$HOSTNAME/') ON DUPLICATE KEY UPDATE \`value\`='http://$HOSTNAME/';
|
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('service_url','http://$HOSTNAME/') ON DUPLICATE KEY UPDATE \`value\`='http://$HOSTNAME/';
|
||||||
|
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('dkim_api_key','http://$DKIM_API_KEY/') ON DUPLICATE KEY UPDATE \`value\`='http://$DKIM_API_KEY/';
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
# Add new user for the mailtrain daemon to run as
|
# Add new user for the mailtrain daemon to run as
|
||||||
|
@ -131,6 +133,13 @@ cat >> config/production.json <<EOT
|
||||||
"bounces": {
|
"bounces": {
|
||||||
"enabled": false,
|
"enabled": false,
|
||||||
"url": "http://localhost/webhooks/zone-mta"
|
"url": "http://localhost/webhooks/zone-mta"
|
||||||
|
},
|
||||||
|
"getSenderConfig": 'http://localhost/webhooks/zone-mta/sender-config?api_token=$DKIM_API_KEY',
|
||||||
|
"zones": {
|
||||||
|
"transactional": {
|
||||||
|
"processes": 1,
|
||||||
|
"connections": 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOT
|
EOT
|
||||||
|
|
|
@ -185,7 +185,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<button type="submit" id="verify-button" form="smtp-verify" class="btn btn-info" data-loading-text="Checking..." ><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Check SMTP config</button>
|
<button type="submit" id="verify-button" form="smtp-verify" class="btn btn-info" data-loading-text="Checking..."><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Check SMTP config</button>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
@ -312,7 +312,53 @@
|
||||||
<label for="pgp-private-key" class="col-sm-2 control-label">GPG Private Key</label>
|
<label for="pgp-private-key" class="col-sm-2 control-label">GPG Private Key</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<textarea class="form-control gpg-text" rows="3" id="pgp-private-key" name="pgp-private-key" placeholder="Begins with '-----BEGIN PGP PRIVATE KEY BLOCK-----'">{{pgpPrivateKey}}</textarea>
|
<textarea class="form-control gpg-text" rows="3" id="pgp-private-key" name="pgp-private-key" placeholder="Begins with '-----BEGIN PGP PRIVATE KEY BLOCK-----'">{{pgpPrivateKey}}</textarea>
|
||||||
<span class="help-block">This value is optional. if you do not provide a private key GPG encrypted messages are sent without signing.</span>
|
<span class="help-block">This value is optional. If you do not provide a private key GPG encrypted messages are sent without signing.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
DKIM Signing by ZoneMTA
|
||||||
|
</legend>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you are using <a href="https://github.com/zone-eu/zone-mta">ZoneMTA</a> then Mailtrain can provide a DKIM key for signing all outgoing messages. Other services usually provide their own means to DKIM sign your messages
|
||||||
|
</p>
|
||||||
|
<p class="text-warning">
|
||||||
|
Do not use sensitive keys here. The private key is not encrypted in the database.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="pgp-passphrase" class="col-sm-2 control-label">ZoneMTA DKIM API Key</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="password" class="form-control" name="dkim-api-key" id="dkim-api-key" placeholder="Some secret value" value="{{dkimApiKey}}">
|
||||||
|
<span class="help-block">Secret value known to ZoneMTA for requesting DKIM key information. If this value was generated by the Mailtrain installation script then you can keep it as it is</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="pgp-passphrase" class="col-sm-2 control-label">DKIM domain</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="text" class="form-control" name="dkim-domain" id="dkim-domain" placeholder="Domain name for the DKIM key" value="{{dkimDomain}}">
|
||||||
|
<span class="help-block">Leave blank to use the sender email address domain</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="pgp-passphrase" class="col-sm-2 control-label">DKIM key selector</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="text" class="form-control" name="dkim-selector" id="dkim-selector" placeholder="DKIM key selector" value="{{dkimSelector}}">
|
||||||
|
<span class="help-block">Signing is disabled without a valid selector value</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="dkim-private-key" class="col-sm-2 control-label">DKIM Private Key</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<textarea class="form-control gpg-text" rows="3" id="dkim-private-key" name="dkim-private-key" placeholder="Begins with '-----BEGIN RSA PRIVATE KEY-----'">{{dkimPrivateKey}}</textarea>
|
||||||
|
<span class="help-block">This value is optional. If you do not provide a private key then messages are not signed.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue