Skip to content

Commit

Permalink
Add SMTP config shortcuts for popular providers in the settings UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Jul 11, 2022
1 parent 278d5bf commit 9107edf
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
8 changes: 8 additions & 0 deletions frontend/src/assets/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,10 @@ section.analytics {
height: auto;
min-height: 350px;
}
.smtp-shortcuts a {
margin-right: 15px;
display: inline-block;
}
}

/* Logs */
Expand Down Expand Up @@ -1034,6 +1038,10 @@ section.analytics {
.page-header .buttons {
display: block;
}

.b-tabs .tab-content {
padding: 15px 0 0 0;
}
}

/* On big sizes, keep the header buttons small and non-expanded. */
Expand Down
47 changes: 46 additions & 1 deletion frontend/src/views/settings/smtp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<b-field grouped>
<b-field :label="$t('settings.mailserver.username')"
label-position="on-border" expanded>
<b-input v-model="item.username"
<b-input v-model="item.username" :custom-class="`smtp-username-${n}`"
:disabled="item.auth_protocol === 'none'"
name="username" placeholder="mysmtp" :maxlength="200" />
</b-field>
Expand All @@ -68,6 +68,15 @@
</b-field>
</div>
</div><!-- auth -->
<div class="smtp-shortcuts is-size-7">
<a href="" @click.prevent="() => fillSettings(n, 'gmail')">Gmail</a>
<a href="" @click.prevent="() => fillSettings(n, 'ses')">Amazon SES</a>
<a href="" @click.prevent="() => fillSettings(n, 'mailgun')">Mailgun</a>
<a href="" @click.prevent="() => fillSettings(n, 'mailjet')">Mailjet</a>
<a href="" @click.prevent="() => fillSettings(n, 'sendgrid')">Sendgrid</a>
<a href="" @click.prevent="() => fillSettings(n, 'postmark')">Postmark</a>
<a href="" @click.prevent="() => fillSettings(n, 'mailersend')">MailerSend</a>
</div>
<hr />

<div class="columns">
Expand Down Expand Up @@ -205,6 +214,27 @@ import Vue from 'vue';
import { mapState } from 'vuex';
import { regDuration } from '../../constants';
const smtpTemplates = {
gmail: {
host: 'smtp.gmail.com', port: 465, auth_protocol: 'login', tls_type: 'TLS',
},
ses: {
host: 'email-smtp.YOUR-REGION.amazonaws.com', port: 465, auth_protocol: 'login', tls_type: 'TLS',
},
mailjet: {
host: 'in-v3.mailjet.com', port: 465, auth_protocol: 'cram', tls_type: 'TLS',
},
mailgun: {
host: 'smtp.mailgun.org', port: 465, auth_protocol: 'login', tls_type: 'TLS',
},
sendgrid: {
host: 'smtp.sendgrid.net', port: 465, auth_protocol: 'login', tls_type: 'TLS',
},
postmark: {
host: 'smtp.postmarkapp.com', port: 587, auth_protocol: 'cram', tls_type: 'STARTTLS',
},
};
export default Vue.extend({
props: {
form: {
Expand Down Expand Up @@ -297,6 +327,21 @@ export default Vue.extend({
return false;
},
fillSettings(n, key) {
this.data.smtp.splice(n, 1, {
...this.data.smtp[n],
...smtpTemplates[key],
username: '',
password: '',
hello_hostname: '',
tls_skip_verify: false,
});
this.$nextTick(() => {
document.querySelector(`.smtp-username-${n}`).focus();
});
},
},
computed: {
Expand Down

0 comments on commit 9107edf

Please sign in to comment.