Skip to content

Commit

Permalink
Add StartTLS encryption option for Fetching Email when Webklex/php-im…
Browse files Browse the repository at this point in the history
…ap is used - closes #3624
  • Loading branch information
freescout-help-desk committed Dec 22, 2023
1 parent eb6b308 commit dc4d6d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions app/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class Mailbox extends Model
const OUT_ENCRYPTION_NONE = 1;
const OUT_ENCRYPTION_SSL = 2;
const OUT_ENCRYPTION_TLS = 3;
// StartTLS is already included in TLS:
// allow_self_signed = true
// verify_peer = false

public static $out_encryptions = [
self::OUT_ENCRYPTION_NONE => '',
Expand All @@ -82,11 +85,16 @@ class Mailbox extends Model
const IN_ENCRYPTION_NONE = 1;
const IN_ENCRYPTION_SSL = 2;
const IN_ENCRYPTION_TLS = 3;
// For Webklex/laravel-imap this option is the same as 'none'.
// For Webklex/php-imap it works:
// https://github.com/Webklex/php-imap/pull/180
const IN_ENCRYPTION_STARTTLS = 4;

public static $in_encryptions = [
self::IN_ENCRYPTION_NONE => '',
self::IN_ENCRYPTION_SSL => 'ssl',
self::IN_ENCRYPTION_TLS => 'tls',
self::IN_ENCRYPTION_STARTTLS => 'starttls',
];

/**
Expand Down
2 changes: 1 addition & 1 deletion resources/views/mailboxes/connection.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<select id="out_encryption" class="form-control input-sized" name="out_encryption" @if ($mailbox->out_method == App\Mailbox::OUT_METHOD_SMTP) required @endif autofocus data-smtp-required="true">
<option value="{{ App\Mailbox::OUT_ENCRYPTION_NONE }}" @if (old('out_encryption', $mailbox->out_encryption) == App\Mailbox::OUT_ENCRYPTION_NONE)selected="selected"@endif>{{ __('None') }}</option>
<option value="{{ App\Mailbox::OUT_ENCRYPTION_SSL }}" @if (old('out_encryption', $mailbox->out_encryption) == App\Mailbox::OUT_ENCRYPTION_SSL)selected="selected"@endif>SSL</option>
<option value="{{ App\Mailbox::OUT_ENCRYPTION_TLS }}" @if (old('out_encryption', $mailbox->out_encryption) == App\Mailbox::OUT_ENCRYPTION_TLS)selected="selected"@endif>TLS</option>
<option value="{{ App\Mailbox::OUT_ENCRYPTION_TLS }}" @if (old('out_encryption', $mailbox->out_encryption) == App\Mailbox::OUT_ENCRYPTION_TLS)selected="selected"@endif>TLS &nbsp;(+StartTLS)</option>
</select>

@include('partials/field_error', ['field'=>'out_encryption'])
Expand Down
9 changes: 7 additions & 2 deletions resources/views/mailboxes/connection_incoming.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,17 @@

<div class="form-group{{ $errors->has('in_encryption') ? ' has-error' : '' }}">
<label for="in_encryption" class="col-sm-2 control-label">{{ __('Encryption') }}</label>

@php
$new_fetching_library = config('app.new_fetching_library');
@endphp
<div class="col-sm-6">
<select id="in_encryption" class="form-control input-sized" name="in_encryption" @if ($mailbox->out_method == App\Mailbox::OUT_METHOD_SMTP) required @endif autofocus>
<option value="{{ App\Mailbox::IN_ENCRYPTION_NONE }}" @if (old('in_encryption', $mailbox->in_encryption) == App\Mailbox::IN_ENCRYPTION_NONE)selected="selected"@endif>{{ __('None') }}</option>
<option value="{{ App\Mailbox::IN_ENCRYPTION_SSL }}" @if (old('in_encryption', $mailbox->in_encryption) == App\Mailbox::IN_ENCRYPTION_SSL)selected="selected"@endif>SSL</option>
<option value="{{ App\Mailbox::IN_ENCRYPTION_TLS }}" @if (old('in_encryption', $mailbox->in_encryption) == App\Mailbox::IN_ENCRYPTION_TLS)selected="selected"@endif>TLS</option>
<option value="{{ App\Mailbox::IN_ENCRYPTION_TLS }}" @if (old('in_encryption', $mailbox->in_encryption) == App\Mailbox::IN_ENCRYPTION_TLS)selected="selected"@endif>{{ 'TLS' }}@if (!$new_fetching_library) &nbsp;(+StartTLS)@endif</option>
@if ($new_fetching_library)
<option value="{{ App\Mailbox::IN_ENCRYPTION_STARTTLS }}" @if (old('in_encryption', $mailbox->in_encryption) == App\Mailbox::IN_ENCRYPTION_STARTTLS)selected="selected"@endif>STARTTLS</option>
@endif
</select>

@include('partials/field_error', ['field'=>'in_encryption'])
Expand Down

0 comments on commit dc4d6d2

Please sign in to comment.