Skip to content

Commit e7f2c48

Browse files
committed
✨ Accept mail configuration options
refs TryGhost#232, TryGhost#216 - this is the most straight forward pass through adding mail config options - there is loads of small tweaks possible here, but they are not required E.g. - auto-set transport to smtp if any other argument is supplied - use grouping to make the output better - stronger use of implies?
1 parent 7ee3f6c commit e7f2c48

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

lib/commands/config/advanced.js

+46
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ const validator = require('validator');
77
const url = require('url');
88

99
const BASE_PORT = '2368';
10+
const knownMailServices = [
11+
'AOL', 'DynectEmail', 'Gmail', 'hot.ee', 'Hotmail', 'iCloud', 'mail.ee', 'Mail.Ru', 'Mailgun',
12+
'Mailjet', 'Mandrill', 'Postmark', 'QQ', 'QQex (Tencent Business Email)', 'SendGrid',
13+
'SendCloud', 'SES', 'Yahoo', 'yandex', 'Zoho'
14+
];
1015

1116
/*
1217
Note: these options are handled serially, i.e. one after the other.
@@ -58,6 +63,8 @@ module.exports = {
5863
defaultValue: (c, env) => env === 'production' ? 'systemd' : 'local',
5964
type: 'string'
6065
},
66+
67+
// Database options
6168
db: {
6269
description: 'Type of database Ghost should use',
6370
validate: value => includes(['sqlite3', 'mysql'], value),
@@ -89,6 +96,45 @@ module.exports = {
8996
configPath: 'database.connection.database',
9097
type: 'string'
9198
},
99+
100+
// Mail options:
101+
// Designed to support the most common mail configs, more advanced configs will require editing the config file
102+
mail: {
103+
description: 'Mail transport, E.g SMTP, Sendmail or Direct',
104+
validate: value => includes(['SMTP', 'Sendmail', 'Direct'], value),
105+
configPath: 'mail.transport',
106+
type: 'string',
107+
default: 'Direct'
108+
},
109+
mailservice: {
110+
description: 'Mail service (used with SMTP transport), E.g. Mailgun, Sendgrid, Gmail, SES...',
111+
configPath: 'mail.options.service',
112+
validate: value => includes(knownMailServices, value),
113+
type: 'string'
114+
},
115+
mailuser: {
116+
description: 'Mail auth user (used with SMTP transport)',
117+
configPath: 'mail.options.auth.user',
118+
type: 'string',
119+
implies: 'mailpass'
120+
},
121+
mailpass: {
122+
description: 'Mail auth pass (used with SMTP transport)',
123+
configPath: 'mail.options.auth.pass',
124+
type: 'string',
125+
implies: 'mailuser'
126+
},
127+
mailhost: {
128+
description: 'Mail host (used with SMTP transport)',
129+
configPath: 'mail.options.host',
130+
type: 'string'
131+
},
132+
mailport: {
133+
description: 'Mail port (used with SMTP transport)',
134+
configPath: 'mail.options.port',
135+
type: 'number'
136+
},
137+
92138
sslemail: {
93139
description: 'SSL email address',
94140
configPath: 'ssl.email',

0 commit comments

Comments
 (0)