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