Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/resources/views/admin/settings/mail.blade.php
7461 views
1
@extends('layouts.admin')
2
@include('partials/admin.settings.nav', ['activeTab' => 'mail'])
3
4
@section('title')
5
Mail Settings
6
@endsection
7
8
@section('content-header')
9
<h1>Mail Settings<small>Configure how Pterodactyl should handle sending emails.</small></h1>
10
<ol class="breadcrumb">
11
<li><a href="{{ route('admin.index') }}">Admin</a></li>
12
<li class="active">Settings</li>
13
</ol>
14
@endsection
15
16
@section('content')
17
@yield('settings::nav')
18
<div class="row">
19
<div class="col-xs-12">
20
<div class="box">
21
<div class="box-header with-border">
22
<h3 class="box-title">Email Settings</h3>
23
</div>
24
@if($disabled)
25
<div class="box-body">
26
<div class="row">
27
<div class="col-xs-12">
28
<div class="alert alert-info no-margin-bottom">
29
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.
30
</div>
31
</div>
32
</div>
33
</div>
34
@else
35
<form>
36
<div class="box-body">
37
<div class="row">
38
<div class="form-group col-md-6">
39
<label class="control-label">SMTP Host</label>
40
<div>
41
<input required type="text" class="form-control" name="mail:mailers:smtp:host" value="{{ old('mail:mailers:smtp:host', config('mail.mailers.smtp.host')) }}" />
42
<p class="text-muted small">Enter the SMTP server address that mail should be sent through.</p>
43
</div>
44
</div>
45
<div class="form-group col-md-2">
46
<label class="control-label">SMTP Port</label>
47
<div>
48
<input required type="number" class="form-control" name="mail:mailers:smtp:port" value="{{ old('mail:mailers:smtp:port', config('mail.mailers.smtp.port')) }}" />
49
<p class="text-muted small">Enter the SMTP server port that mail should be sent through.</p>
50
</div>
51
</div>
52
<div class="form-group col-md-4">
53
<label class="control-label">Encryption</label>
54
<div>
55
@php
56
$encryption = old('mail:mailers:smtp:encryption', config('mail.mailers.smtp.encryption'));
57
@endphp
58
<select name="mail:mailers:smtp:encryption" class="form-control">
59
<option value="" @if($encryption === '') selected @endif>None</option>
60
<option value="tls" @if($encryption === 'tls') selected @endif>Transport Layer Security (TLS)</option>
61
<option value="ssl" @if($encryption === 'ssl') selected @endif>Secure Sockets Layer (SSL)</option>
62
</select>
63
<p class="text-muted small">Select the type of encryption to use when sending mail.</p>
64
</div>
65
</div>
66
<div class="form-group col-md-6">
67
<label class="control-label">Username <span class="field-optional"></span></label>
68
<div>
69
<input type="text" class="form-control" name="mail:mailers:smtp:username" value="{{ old('mail:mailers:smtp:username', config('mail.mailers.smtp.username')) }}" />
70
<p class="text-muted small">The username to use when connecting to the SMTP server.</p>
71
</div>
72
</div>
73
<div class="form-group col-md-6">
74
<label class="control-label">Password <span class="field-optional"></span></label>
75
<div>
76
<input type="password" class="form-control" name="mail:mailers:smtp:password"/>
77
<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>
78
</div>
79
</div>
80
</div>
81
<div class="row">
82
<hr />
83
<div class="form-group col-md-6">
84
<label class="control-label">Mail From</label>
85
<div>
86
<input required type="email" class="form-control" name="mail:from:address" value="{{ old('mail:from:address', config('mail.from.address')) }}" />
87
<p class="text-muted small">Enter an email address that all outgoing emails will originate from.</p>
88
</div>
89
</div>
90
<div class="form-group col-md-6">
91
<label class="control-label">Mail From Name <span class="field-optional"></span></label>
92
<div>
93
<input type="text" class="form-control" name="mail:from:name" value="{{ old('mail:from:name', config('mail.from.name')) }}" />
94
<p class="text-muted small">The name that emails should appear to come from.</p>
95
</div>
96
</div>
97
</div>
98
</div>
99
<div class="box-footer">
100
{{ csrf_field() }}
101
<div class="pull-right">
102
<button type="button" id="testButton" class="btn btn-sm btn-success">Test</button>
103
<button type="button" id="saveButton" class="btn btn-sm btn-primary">Save</button>
104
</div>
105
</div>
106
</form>
107
@endif
108
</div>
109
</div>
110
</div>
111
@endsection
112
113
@section('footer-scripts')
114
@parent
115
116
<script>
117
function saveSettings() {
118
return $.ajax({
119
method: 'PATCH',
120
url: '/admin/settings/mail',
121
contentType: 'application/json',
122
data: JSON.stringify({
123
'mail:mailers:smtp:host': $('input[name="mail:mailers:smtp:host"]').val(),
124
'mail:mailers:smtp:port': $('input[name="mail:mailers:smtp:port"]').val(),
125
'mail:mailers:smtp:encryption': $('select[name="mail:mailers:smtp:encryption"]').val(),
126
'mail:mailers:smtp:username': $('input[name="mail:mailers:smtp:username"]').val(),
127
'mail:mailers:smtp:password': $('input[name="mail:mailers:smtp:password"]').val(),
128
'mail:from:address': $('input[name="mail:from:address"]').val(),
129
'mail:from:name': $('input[name="mail:from:name"]').val()
130
}),
131
headers: { 'X-CSRF-Token': $('input[name="_token"]').val() }
132
}).fail(function (jqXHR) {
133
showErrorDialog(jqXHR, 'save');
134
});
135
}
136
137
function testSettings() {
138
swal({
139
type: 'info',
140
title: 'Test Mail Settings',
141
text: 'Click "Test" to begin the test.',
142
showCancelButton: true,
143
confirmButtonText: 'Test',
144
closeOnConfirm: false,
145
showLoaderOnConfirm: true
146
}, function () {
147
$.ajax({
148
method: 'POST',
149
url: '/admin/settings/mail/test',
150
headers: { 'X-CSRF-TOKEN': $('input[name="_token"]').val() }
151
}).fail(function (jqXHR) {
152
showErrorDialog(jqXHR, 'test');
153
}).done(function () {
154
swal({
155
title: 'Success',
156
text: 'The test message was sent successfully.',
157
type: 'success'
158
});
159
});
160
});
161
}
162
163
function saveAndTestSettings() {
164
saveSettings().done(testSettings);
165
}
166
167
function showErrorDialog(jqXHR, verb) {
168
console.error(jqXHR);
169
var errorText = '';
170
if (!jqXHR.responseJSON) {
171
errorText = jqXHR.responseText;
172
} else if (jqXHR.responseJSON.error) {
173
errorText = jqXHR.responseJSON.error;
174
} else if (jqXHR.responseJSON.errors) {
175
$.each(jqXHR.responseJSON.errors, function (i, v) {
176
if (v.detail) {
177
errorText += v.detail + ' ';
178
}
179
});
180
}
181
182
swal({
183
title: 'Whoops!',
184
text: 'An error occurred while attempting to ' + verb + ' mail settings: ' + errorText,
185
type: 'error'
186
});
187
}
188
189
$(document).ready(function () {
190
$('#testButton').on('click', saveAndTestSettings);
191
$('#saveButton').on('click', function () {
192
saveSettings().done(function () {
193
swal({
194
title: 'Success',
195
text: 'Mail settings have been updated successfully and the queue worker was restarted to apply these changes.',
196
type: 'success'
197
});
198
});
199
});
200
});
201
</script>
202
@endsection
203
204