better smtp setup, allow local sendmail, add secure flag, auth not required
This commit is contained in:
@@ -4,22 +4,34 @@
|
|||||||
v-card-text
|
v-card-text
|
||||||
p(v-html="$t('admin.smtp_description')")
|
p(v-html="$t('admin.smtp_description')")
|
||||||
v-form(v-model='isValid')
|
v-form(v-model='isValid')
|
||||||
|
|
||||||
v-text-field(v-model='admin_email'
|
v-text-field(v-model='admin_email'
|
||||||
@blur="save('admin_email', admin_email )"
|
@blur="save('admin_email', admin_email )"
|
||||||
:label="$t('admin.admin_email')"
|
:label="$t('admin.sender_email')"
|
||||||
:rules="$validators.email")
|
:rules="$validators.email")
|
||||||
v-text-field(v-model='smtp.host'
|
|
||||||
:label="$t('admin.smtp_hostname')"
|
|
||||||
:rules="[$validators.required('admin.smtp_hostname')]")
|
|
||||||
|
|
||||||
v-text-field(v-model='smtp.auth.user'
|
v-switch(v-model='smtp.sendmail'
|
||||||
:label="$t('common.user')"
|
:label="$t('admin.smtp_use_sendmail')")
|
||||||
:rules="[$validators.required('common.user')]")
|
|
||||||
|
|
||||||
v-text-field(v-model='smtp.auth.pass'
|
template(v-if='!smtp.sendmail')
|
||||||
:label="$t('common.password')"
|
|
||||||
:rules="[$validators.required('common.password')]"
|
v-text-field(v-model='smtp.host'
|
||||||
type='password')
|
:label="$t('admin.smtp_hostname')"
|
||||||
|
:rules="[$validators.required('admin.smtp_hostname')]")
|
||||||
|
|
||||||
|
v-text-field(v-model='smtp.port'
|
||||||
|
:label="$t('admin.smtp_port')"
|
||||||
|
:rules="[$validators.required('admin.smtp_port')]")
|
||||||
|
|
||||||
|
v-switch(v-model='smtp.secure'
|
||||||
|
:label="$t('admin.smtp_secure')")
|
||||||
|
|
||||||
|
v-text-field(v-model='smtp.auth.user'
|
||||||
|
:label="$t('common.user')")
|
||||||
|
|
||||||
|
v-text-field(v-model='smtp.auth.pass'
|
||||||
|
:label="$t('common.password')"
|
||||||
|
type='password')
|
||||||
|
|
||||||
v-card-actions
|
v-card-actions
|
||||||
v-spacer
|
v-spacer
|
||||||
@@ -31,14 +43,16 @@
|
|||||||
import { mapActions, mapState } from 'vuex'
|
import { mapActions, mapState } from 'vuex'
|
||||||
export default {
|
export default {
|
||||||
data ({ $store }) {
|
data ({ $store }) {
|
||||||
const smtp = { host: '', auth: { user: '', pass: '' } }
|
const smtp = { auth: {}, ...$store.state.settings.smtp }
|
||||||
if ($store.state.settings.smtp) {
|
// if ($store.state.settings.smtp) {
|
||||||
smtp.host = $store.state.settings.smtp.host
|
// smtp.host = $store.state.settings.smtp.host
|
||||||
if ($store.state.settings.smtp.auth) {
|
// if ($store.state.settings.smtp.auth) {
|
||||||
smtp.auth.user = $store.state.settings.smtp.auth.user
|
// smtp.auth.user = $store.state.settings.smtp.auth.user
|
||||||
smtp.auth.pass = $store.state.settings.smtp.auth.pass
|
// smtp.auth.pass = $store.state.settings.smtp.auth.pass
|
||||||
}
|
// } else {
|
||||||
}
|
// smtp.auth = {}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
return {
|
return {
|
||||||
isValid: false,
|
isValid: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
@@ -47,13 +61,28 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: mapState(['settings']),
|
computed: mapState(['settings']),
|
||||||
|
watch: {
|
||||||
|
'smtp.secure' (value) {
|
||||||
|
this.smtp.port = value ? 465 : 25
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['setSetting']),
|
...mapActions(['setSetting']),
|
||||||
async testSMTP () {
|
async testSMTP () {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
try {
|
try {
|
||||||
await this.setSetting({ key: 'smtp', value: this.smtp })
|
const smtp = JSON.parse(JSON.stringify(this.smtp))
|
||||||
await this.$axios.$post('/settings/smtp', { smtp: this.smtp })
|
console.error(smtp)
|
||||||
|
if (!smtp.auth.user) {
|
||||||
|
console.error('ma non sono qui dentro !??!')
|
||||||
|
delete smtp.auth
|
||||||
|
}
|
||||||
|
if (!smtp.secure) {
|
||||||
|
smtp.secure = false
|
||||||
|
smtp.ignoreTLS = true
|
||||||
|
}
|
||||||
|
// await this.setSetting({ key: 'smtp', value: JSON.parse(JSON.stringify(this.smtp)) })
|
||||||
|
await this.$axios.$post('/settings/smtp', { smtp })
|
||||||
this.$root.$message(this.$t('admin.smtp_test_success', { admin_email: this.admin_email }), { color: 'success' })
|
this.$root.$message(this.$t('admin.smtp_test_success', { admin_email: this.admin_email }), { color: 'success' })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
@@ -67,9 +96,15 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
done () {
|
done () {
|
||||||
if (this.smtp.auth.pass) {
|
const smtp = JSON.parse(JSON.stringify(this.smtp))
|
||||||
this.setSetting({ key: 'smtp', value: JSON.parse(JSON.stringify(this.smtp)) })
|
if (!smtp.auth.user) {
|
||||||
|
delete smtp.auth
|
||||||
}
|
}
|
||||||
|
if (!smtp.secure) {
|
||||||
|
smtp.secure = false
|
||||||
|
smtp.ignoreTLS = true
|
||||||
|
}
|
||||||
|
this.setSetting({ key: 'smtp', value: smtp })
|
||||||
this.$emit('close')
|
this.$emit('close')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState(['settings']),
|
...mapState(['settings']),
|
||||||
showSMTPAlert () {
|
showSMTPAlert () {
|
||||||
return !this.setup && (!this.settings.admin_email || !this.settings.smtp || !this.settings.smtp.host || !this.settings.smtp.auth.user)
|
return !this.setup &&
|
||||||
|
(!this.settings.admin_email || !this.settings.smtp || (!this.settings.smtp.sendmail && !this.settings.smtp.host))
|
||||||
},
|
},
|
||||||
instance_locale: {
|
instance_locale: {
|
||||||
get () { return this.settings.instance_locale },
|
get () { return this.settings.instance_locale },
|
||||||
|
|||||||
@@ -229,10 +229,13 @@
|
|||||||
"new_announcement": "New announcement",
|
"new_announcement": "New announcement",
|
||||||
"show_smtp_setup": "Email settings",
|
"show_smtp_setup": "Email settings",
|
||||||
"smtp_hostname": "SMTP Hostname",
|
"smtp_hostname": "SMTP Hostname",
|
||||||
|
"smtp_port": "SMTP Port",
|
||||||
|
"smtp_secure": "SMTP Secure (TLS or STARTTLS)",
|
||||||
"smtp_description": "<ul><li>Admin should receive an email when anon event is added (if enabled).</li><li>Admin should receive email of registration request (if enabled).</li><li>User should receive an email of registration request.</li><li>User should receive email of confirmed registration.</li><li>User should receive a confirmation email when subscribed directly by admin.</li><li>Users should receive email to restore password when they forgot it</li></ul>",
|
"smtp_description": "<ul><li>Admin should receive an email when anon event is added (if enabled).</li><li>Admin should receive email of registration request (if enabled).</li><li>User should receive an email of registration request.</li><li>User should receive email of confirmed registration.</li><li>User should receive a confirmation email when subscribed directly by admin.</li><li>Users should receive email to restore password when they forgot it</li></ul>",
|
||||||
"smtp_test_success": "A test email is sent to {admin_email}, please check your inbox",
|
"smtp_test_success": "A test email is sent to {admin_email}, please check your inbox",
|
||||||
"smtp_test_button": "Send a test email",
|
"smtp_test_button": "Send a test email",
|
||||||
"admin_email": "Admin e-mail",
|
"smtp_use_sendmail": "Use sendmail",
|
||||||
|
"sender_email": "Sender e-mail",
|
||||||
"widget": "Widget",
|
"widget": "Widget",
|
||||||
"wrong_domain_warning": "The baseurl configured in config.json <b>({baseurl})</b> differs from the one you're visiting <b>({url})</b>",
|
"wrong_domain_warning": "The baseurl configured in config.json <b>({baseurl})</b> differs from the one you're visiting <b>({url})</b>",
|
||||||
"new_collection": "New collection",
|
"new_collection": "New collection",
|
||||||
|
|||||||
@@ -227,7 +227,7 @@
|
|||||||
"new_announcement": "Nuovo annuncio",
|
"new_announcement": "Nuovo annuncio",
|
||||||
"show_smtp_setup": "Impostazioni email",
|
"show_smtp_setup": "Impostazioni email",
|
||||||
"widget": "Widget",
|
"widget": "Widget",
|
||||||
"smtp_description": "<ul><li>L'amministratore riceve una email quando viene aggiunto un evento anonimo (se abilitati).</li><li>L'amministratore riceve le mail di richiesta di registrazione (se abilitata).</li><li>L persone ricevono una mail di conferma della registrazione richiesta.</li><li>Le persone ricevono le email della registrazione confermata.</li><li>Le persone ricevono una mail di avviso quando vengono registrate direttamente da admin.</li><li>Le persone ricevono la mail per modificare la password quando l'hanno dimenticata</li></ul>",
|
"smtp_description": "<ul><li>L'amministratore riceve una email quando viene aggiunto un evento anonimo (se abilitati).</li><li>L'amministratore riceve le mail di richiesta di registrazione (se abilitata).</li><li>Le persone ricevono una mail di conferma della registrazione richiesta.</li><li>Le persone ricevono le email della registrazione confermata.</li><li>Le persone ricevono una mail di avviso quando vengono registrate direttamente da admin.</li><li>Le persone ricevono la mail per modificare la password quando l'hanno dimenticata</li></ul>",
|
||||||
"smtp_hostname": "SMTP Hostname",
|
"smtp_hostname": "SMTP Hostname",
|
||||||
"smtp_test_success": "Una mail di test è stata inviata all'indirizzo {admin_email}, controlla la tua casella di posta",
|
"smtp_test_success": "Una mail di test è stata inviata all'indirizzo {admin_email}, controlla la tua casella di posta",
|
||||||
"smtp_test_button": "Invia una mail di prova",
|
"smtp_test_button": "Invia una mail di prova",
|
||||||
|
|||||||
Reference in New Issue
Block a user