2017-12-15 03:05:26 +00:00
|
|
|
@extends('layouts.admin')
|
|
|
|
@include('partials/admin.settings.nav', ['activeTab' => 'mail'])
|
|
|
|
|
|
|
|
@section('title')
|
|
|
|
Mail Settings
|
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section('content-header')
|
|
|
|
<h1>Mail Settings<small>Configure how Pterodactyl should handle sending emails.</small></h1>
|
|
|
|
<ol class="breadcrumb">
|
|
|
|
<li><a href="{{ route('admin.index') }}">Admin</a></li>
|
|
|
|
<li class="active">Settings</li>
|
|
|
|
</ol>
|
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section('content')
|
|
|
|
@yield('settings::nav')
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-xs-12">
|
|
|
|
<div class="box">
|
|
|
|
<div class="box-header with-border">
|
|
|
|
<h3 class="box-title">Email Settings</h3>
|
|
|
|
</div>
|
|
|
|
@if($disabled)
|
|
|
|
<div class="box-body">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-xs-12">
|
|
|
|
<div class="alert alert-info no-margin-bottom">
|
|
|
|
This interface is limited to instances using SMTP as the mail driver. Please either use <code>php artisan p:environment:mail</code> command to update your email settings, or set <code>MAIL_DRIVER=smtp</code> in your environment file.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@else
|
2018-09-16 02:49:16 +00:00
|
|
|
<form>
|
2017-12-15 03:05:26 +00:00
|
|
|
<div class="box-body">
|
|
|
|
<div class="row">
|
|
|
|
<div class="form-group col-md-6">
|
|
|
|
<label class="control-label">SMTP Host</label>
|
|
|
|
<div>
|
|
|
|
<input required type="text" class="form-control" name="mail:host" value="{{ old('mail:host', config('mail.host')) }}" />
|
|
|
|
<p class="text-muted small">Enter the SMTP server address that mail should be sent through.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-2">
|
|
|
|
<label class="control-label">SMTP Port</label>
|
|
|
|
<div>
|
|
|
|
<input required type="number" class="form-control" name="mail:port" value="{{ old('mail:port', config('mail.port')) }}" />
|
|
|
|
<p class="text-muted small">Enter the SMTP server port that mail should be sent through.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
|
|
<label class="control-label">Encryption</label>
|
|
|
|
<div>
|
|
|
|
@php
|
|
|
|
$encryption = old('mail:encryption', config('mail.encryption'));
|
|
|
|
@endphp
|
|
|
|
<select name="mail:encryption" class="form-control">
|
|
|
|
<option value="" @if($encryption === '') selected @endif>None</option>
|
|
|
|
<option value="tls" @if($encryption === 'tls') selected @endif>Transport Layer Security (TLS)</option>
|
|
|
|
<option value="ssl" @if($encryption === 'ssl') selected @endif>Secure Sockets Layer (SSL)</option>
|
|
|
|
</select>
|
|
|
|
<p class="text-muted small">Select the type of encryption to use when sending mail.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-6">
|
|
|
|
<label class="control-label">Username <span class="field-optional"></span></label>
|
|
|
|
<div>
|
|
|
|
<input type="text" class="form-control" name="mail:username" value="{{ old('mail:username', config('mail.username')) }}" />
|
|
|
|
<p class="text-muted small">The username to use when connecting to the SMTP server.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-6">
|
|
|
|
<label class="control-label">Password <span class="field-optional"></span></label>
|
|
|
|
<div>
|
|
|
|
<input type="password" class="form-control" name="mail:password"/>
|
|
|
|
<p class="text-muted small">The password to use in conjunction with the SMTP username. Leave blank to continue using the existing password. To set the password to an empty value enter <code>!e</code> into the field.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<hr />
|
|
|
|
<div class="form-group col-md-6">
|
|
|
|
<label class="control-label">Mail From</label>
|
|
|
|
<div>
|
|
|
|
<input required type="email" class="form-control" name="mail:from:address" value="{{ old('mail:from:address', config('mail.from.address')) }}" />
|
|
|
|
<p class="text-muted small">Enter an email address that all outgoing emails will originate from.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-6">
|
|
|
|
<label class="control-label">Mail From Name <span class="field-optional"></span></label>
|
|
|
|
<div>
|
|
|
|
<input type="text" class="form-control" name="mail:from:name" value="{{ old('mail:from:name', config('mail.from.name')) }}" />
|
|
|
|
<p class="text-muted small">The name that emails should appear to come from.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="box-footer">
|
|
|
|
{{ csrf_field() }}
|
2018-09-15 23:43:22 +00:00
|
|
|
<div class="pull-right">
|
2018-09-16 02:49:16 +00:00
|
|
|
<button type="button" id="testButton" class="btn btn-sm btn-success">Test</button>
|
|
|
|
<button type="button" id="saveButton" class="btn btn-sm btn-primary">Save</button>
|
2018-09-15 23:43:22 +00:00
|
|
|
</div>
|
2017-12-15 03:05:26 +00:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
@endif
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@endsection
|
2018-09-16 02:49:16 +00:00
|
|
|
|
|
|
|
@section('footer-scripts')
|
2019-07-26 15:17:18 +00:00
|
|
|
@parent
|
2019-12-16 02:19:35 +00:00
|
|
|
|
2018-09-16 02:49:16 +00:00
|
|
|
<script>
|
|
|
|
function saveSettings() {
|
|
|
|
return $.ajax({
|
|
|
|
method: 'PATCH',
|
2019-12-16 02:19:35 +00:00
|
|
|
url: '/admin/settings/mail',
|
2018-09-16 02:49:16 +00:00
|
|
|
contentType: 'application/json',
|
|
|
|
data: JSON.stringify({
|
|
|
|
'mail:host': $('input[name="mail:host"]').val(),
|
|
|
|
'mail:port': $('input[name="mail:port"]').val(),
|
|
|
|
'mail:encryption': $('select[name="mail:encryption"]').val(),
|
|
|
|
'mail:username': $('input[name="mail:username"]').val(),
|
|
|
|
'mail:password': $('input[name="mail:password"]').val(),
|
|
|
|
'mail:from:address': $('input[name="mail:from:address"]').val(),
|
|
|
|
'mail:from:name': $('input[name="mail:from:name"]').val()
|
|
|
|
}),
|
|
|
|
headers: { 'X-CSRF-Token': $('input[name="_token"]').val() }
|
|
|
|
}).fail(function (jqXHR) {
|
|
|
|
showErrorDialog(jqXHR, 'save');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function testSettings() {
|
2018-09-16 16:14:21 +00:00
|
|
|
swal({
|
|
|
|
type: 'info',
|
|
|
|
title: 'Test Mail Settings',
|
|
|
|
text: 'Click "Test" to begin the test.',
|
|
|
|
showCancelButton: true,
|
|
|
|
confirmButtonText: 'Test',
|
|
|
|
closeOnConfirm: false,
|
|
|
|
showLoaderOnConfirm: true
|
|
|
|
}, function () {
|
|
|
|
$.ajax({
|
2021-11-17 04:02:18 +00:00
|
|
|
method: 'POST',
|
2019-12-16 02:19:35 +00:00
|
|
|
url: '/admin/settings/mail/test',
|
2021-11-17 04:02:18 +00:00
|
|
|
headers: { 'X-CSRF-TOKEN': $('input[name="_token"]').val() }
|
2018-09-16 16:14:21 +00:00
|
|
|
}).fail(function (jqXHR) {
|
|
|
|
showErrorDialog(jqXHR, 'test');
|
|
|
|
}).done(function () {
|
|
|
|
swal({
|
|
|
|
title: 'Success',
|
|
|
|
text: 'The test message was sent successfully.',
|
|
|
|
type: 'success'
|
|
|
|
});
|
2018-09-16 02:49:16 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveAndTestSettings() {
|
|
|
|
saveSettings().done(testSettings);
|
|
|
|
}
|
|
|
|
|
|
|
|
function showErrorDialog(jqXHR, verb) {
|
|
|
|
console.error(jqXHR);
|
2018-09-16 16:13:59 +00:00
|
|
|
var errorText = '';
|
2018-09-16 03:15:12 +00:00
|
|
|
if (!jqXHR.responseJSON) {
|
|
|
|
errorText = jqXHR.responseText;
|
|
|
|
} else if (jqXHR.responseJSON.error) {
|
2018-09-16 02:49:16 +00:00
|
|
|
errorText = jqXHR.responseJSON.error;
|
|
|
|
} else if (jqXHR.responseJSON.errors) {
|
|
|
|
$.each(jqXHR.responseJSON.errors, function (i, v) {
|
2018-09-16 16:13:59 +00:00
|
|
|
if (v.detail) {
|
|
|
|
errorText += v.detail + ' ';
|
|
|
|
}
|
2018-09-16 02:49:16 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
swal({
|
|
|
|
title: 'Whoops!',
|
|
|
|
text: 'An error occurred while attempting to ' + verb + ' mail settings: ' + errorText,
|
|
|
|
type: 'error'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$('#testButton').on('click', saveAndTestSettings);
|
|
|
|
$('#saveButton').on('click', function () {
|
|
|
|
saveSettings().done(function () {
|
|
|
|
swal({
|
|
|
|
title: 'Success',
|
|
|
|
text: 'Mail settings have been updated successfully and the queue worker was restarted to apply these changes.',
|
|
|
|
type: 'success'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
@endsection
|