Skip to content

Commit

Permalink
fix(mailcheck): added option for less secure certs in mailcheck
Browse files Browse the repository at this point in the history
PR#434 by @hkpanchani
  • Loading branch information
polonel committed Sep 19, 2021
1 parent 92f8770 commit 0e6fd69
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/client/containers/Settings/Mailer/mailerCheck.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Mailer_MailerCheck extends React.Component {
mailerCheckPort: '',
mailerCheckUsername: '',
mailerCheckPassword: '',
mailerCheckSelfSign: '',
mailerCheckPolling: '',
mailerCheckCreateAccount: '',
mailerCheckDeleteMessage: '',
Expand Down Expand Up @@ -65,6 +66,8 @@ class Mailer_MailerCheck extends React.Component {
stateObj.mailerCheckUsername = nextProps.settings.getIn(['settings', 'mailerCheckUsername', 'value']) || ''
if (!state.mailerCheckPassword)
stateObj.mailerCheckPassword = nextProps.settings.getIn(['settings', 'mailerCheckPassword', 'value']) || ''
if (state.mailerCheckSelfSign === '')
stateObj.mailerCheckSelfSign = nextProps.settings.getIn(['settings', 'mailerCheckSelfSign', 'value']) || ''
if (state.mailerCheckPolling === '')
stateObj.mailerCheckPolling =
parseInt(nextProps.settings.getIn(['settings', 'mailerCheckPolling', 'value'])) / 60000 || ''
Expand Down Expand Up @@ -124,6 +127,7 @@ class Mailer_MailerCheck extends React.Component {
{ name: 'mailer:check:port', value: this.state.mailerCheckPort },
{ name: 'mailer:check:username', value: this.state.mailerCheckUsername },
{ name: 'mailer:check:password', value: this.state.mailerCheckPassword },
{ name: 'mailer:check:selfsign', value: this.state.mailerCheckSelfSign },
{ name: 'mailer:check:ticketype', value: this.state.mailerCheckTicketType },
{ name: 'mailer:check:ticketpriority', value: this.state.mailerCheckTicketPriority },
{ name: 'mailer:check:createaccount', value: this.state.mailerCheckCreateAccount },
Expand Down Expand Up @@ -270,6 +274,29 @@ class Mailer_MailerCheck extends React.Component {
disabled={!this.getSetting('mailerCheckEnabled')}
/>
</div>
<div className='uk-clearfix uk-margin-medium-bottom'>
<div className='uk-float-left'>
<h6 style={{ padding: 0, margin: '5px 0 0 0', fontSize: '16px', lineHeight: '14px' }}>
Allow Self Signed Certificate
</h6>
<h5
style={{ padding: '0 0 10px 0', margin: '2px 0 0 0', fontSize: '12px' }}
className={'uk-text-muted'}
>
Allow less secure self signed certificates when checking mailbox.
</h5>
</div>
<div className='uk-float-right'>
<EnableSwitch
label={'Enable'}
stateName={'mailerCheckCreateAccount'}
checked={this.state.mailerCheckSelfSign}
onChange={e => this.onCheckboxChanged(e, 'mailerCheckSelfSign')}
disabled={!this.getSetting('mailerCheckEnabled')}
/>
</div>
<hr style={{ float: 'left', marginTop: '10px' }} />
</div>
<div className='uk-clearfix uk-margin-medium-bottom'>
<div className='uk-float-left'>
<h6 style={{ padding: 0, margin: '5px 0 0 0', fontSize: '16px', lineHeight: '14px' }}>
Expand Down
11 changes: 10 additions & 1 deletion src/mailer/mailCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ mailCheck.init = function (settings) {
s.mailerCheckPassword = _.find(settings, function (x) {
return x.name === 'mailer:check:password'
})
s.mailerCheckSelfSign = _.find(settings, function (x) {
return x.name === 'mailer:check:selfsign'
})
s.mailerCheckPolling = _.find(settings, function (x) {
return x.name === 'mailer:check:polling'
})
Expand All @@ -67,6 +70,7 @@ mailCheck.init = function (settings) {
s.mailerCheckPort = s.mailerCheckPort === undefined ? { value: 143 } : s.mailerCheckPort
s.mailerCheckUsername = s.mailerCheckUsername === undefined ? { value: '' } : s.mailerCheckUsername
s.mailerCheckPassword = s.mailerCheckPassword === undefined ? { value: '' } : s.mailerCheckPassword
s.mailerCheckSelfSign = s.mailerCheckSelfSign === undefined ? { value: false } : s.mailerCheckSelfSign
s.mailerCheckPolling = s.mailerCheckPolling === undefined ? { value: 600000 } : s.mailerCheckPolling // 10 min
s.mailerCheckTicketType = s.mailerCheckTicketType === undefined ? { value: 'Issue' } : s.mailerCheckTicketType
s.mailerCheckTicketPriority = s.mailerCheckTicketPriority === undefined ? { value: '' } : s.mailerCheckTicketPriority
Expand All @@ -79,16 +83,21 @@ mailCheck.init = function (settings) {
var MAILERCHECK_PASS = s.mailerCheckPassword.value
var MAILERCHECK_PORT = s.mailerCheckPort.value
var MAILERCHECK_TLS = s.mailerCheckPort.value === '993'
var MAILERCHECK_SELFSIGN = s.mailerCheckSelfSign.value
var POLLING_INTERVAL = s.mailerCheckPolling.value

if (!MAILERCHECK_ENABLED) return true

var tlsOptions = {}
if (MAILERCHECK_SELFSIGN) tlsOptions = { rejectUnauthorized: false }

mailCheck.Imap = new Imap({
user: MAILERCHECK_USER,
password: MAILERCHECK_PASS,
host: MAILERCHECK_HOST,
port: MAILERCHECK_PORT,
tls: MAILERCHECK_TLS
tls: MAILERCHECK_TLS,
tlsOptions: tlsOptions
})

mailCheck.fetchMailOptions = {
Expand Down
1 change: 1 addition & 0 deletions src/settings/settingsUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ util.getSettings = function (callback) {
s.mailerCheckPort = parseSetting(settings, 'mailer:check:port', 143)
s.mailerCheckUsername = parseSetting(settings, 'mailer:check:username', '')
s.mailerCheckPassword = parseSetting(settings, 'mailer:check:password', '')
s.mailerCheckSelfSign = parseSetting(settings, 'mailer:check:selfsign', false)
s.mailerCheckTicketType = parseSetting(settings, 'mailer:check:ticketype', '')
s.mailerCheckTicketPriority = parseSetting(settings, 'mailer:check:ticketpriority', '')
s.mailerCheckCreateAccount = parseSetting(settings, 'mailer:check:createaccount', false)
Expand Down

0 comments on commit 0e6fd69

Please sign in to comment.