email.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. @extends('admin/public/layout')
  2. @section('title')邮箱配置@endsection
  3. @section('content')
  4. <section class="content-header">
  5. <h1>邮箱配置</h1>
  6. </section>
  7. <section class="content">
  8. <div class="row">
  9. <div class="col-xs-12">
  10. <div class="box box-primary">
  11. <form role="form" name="settingForm" method="POST" action="{{ route('admin.setting.email') }}">
  12. <input type="hidden" name="_token" value="{{ csrf_token() }}">
  13. <div class="box-body">
  14. <div class="form-group">
  15. <label for="website_url">开启邮件功能</label>
  16. <span class="text-muted">(若关闭则不会有邮件通知)</span>
  17. <div class="radio">
  18. <label><input type="radio" name="mail_open" value="1" @if(Setting()->get('mail_open') == 1) checked @endif > 开启 </label>
  19. <label class="ml-20"><input type="radio" name="mail_open" value="0" @if(Setting()->get('mail_open') != 1) checked @endif > 关闭 </label>
  20. </div>
  21. </div>
  22. <div class="form-group @if ($errors->has('mail_from_address')) has-error @endif">
  23. <label for="mail_from_address">邮件来源地址</label>
  24. <span class="text-muted">(默认跟发送账号保持一致,例如tipask@qq.com)</span>
  25. <input type="text" name="mail_from_address" class="form-control " placeholder="邮件来源地址" value="{{ old('mail_from_address',Setting()->get('mail_from_address')) }}">
  26. @if ($errors->has('mail_from_address')) <p class="help-block">{{ $errors->first('mail_from_address') }}</p> @endif
  27. </div>
  28. <div class="form-group @if ($errors->has('mail_from_name')) has-error @endif">
  29. <label for="mail_from_name">邮件来源名称</label>
  30. <span class="text-muted">(显示邮件名称部分,例如tipask)</span>
  31. <input type="text" name="mail_from_name" class="form-control " placeholder="邮件来源名称" value="{{ old('mail_from_name',Setting()->get('mail_from_name')) }}">
  32. @if ($errors->has('mail_from_name')) <p class="help-block">{{ $errors->first('mail_from_name') }}</p> @endif
  33. </div>
  34. <div class="form-group">
  35. <label for="mail_driver" >邮件类型</label>
  36. <span class="text-muted">(邮件发送方式)</span>
  37. <select name="mail_driver" id="mail_driver" class="form-control">
  38. @foreach(config('tipask.mail_drivers') as $name => $text)
  39. <option value="{{ $name }}" @if(Setting()->get('mail_driver','smtp') == $name ) selected @endif >{{ $text }}</option>
  40. @endforeach
  41. </select>
  42. </div>
  43. <div class="form-group smtp-item @if ($errors->has('mail_host')) has-error @endif">
  44. <label for="mail_host">SMTP 服务器</label>
  45. <span class="text-muted">(例如smtp.qq.com)</span>
  46. <input type="text" name="mail_host" class="form-control " placeholder="邮件服务器地址" value="{{ old('mail_host',Setting()->get('mail_host')) }}">
  47. @if ($errors->has('mail_host')) <p class="help-block">{{ $errors->first('mail_host') }}</p> @endif
  48. </div>
  49. <div class="form-group smtp-item @if ($errors->has('mail_port')) has-error @endif">
  50. <label for="mail_port">SMTP 端口</label>
  51. <span class="text-muted">(设置 SMTP 服务器的端口,默认为 25)</span>
  52. <input type="text" name="mail_port" class="form-control " placeholder="SMTP 端口 默认25" value="{{ old('mail_port',Setting()->get('mail_port')) }}">
  53. @if ($errors->has('mail_port')) <p class="help-block">{{ $errors->first('mail_port') }}</p> @endif
  54. </div>
  55. <div class="form-group smtp-item">
  56. <label>邮件安全加密方式</label>
  57. <span class="text-muted">(请根据邮件实际情况进行配置)</span>
  58. <div class="radio">
  59. <label><input type="radio" name="mail_encryption" value="null" @if(Setting()->get('mail_encryption','null') == 'null') checked @endif > 无 </label>&nbsp;&nbsp;
  60. <label><input type="radio" name="mail_encryption" value="ssl" @if(Setting()->get('mail_encryption') == 'ssl') checked @endif > SSL </label>&nbsp;&nbsp;
  61. <label><input type="radio" name="mail_encryption" value="tls" @if(Setting()->get('mail_encryption') == 'tls') checked @endif > TLS </label>
  62. </div>
  63. </div>
  64. <div class="form-group smtp-item @if ($errors->has('mail_username')) has-error @endif">
  65. <label for="mail_username">邮箱地址</label>
  66. <span class="text-muted">(例如tipask@qq.com)</span>
  67. <input type="text" name="mail_username" class="form-control " placeholder="邮件服务器地址" value="{{ old('mail_username',Setting()->get('mail_username')) }}">
  68. @if ($errors->has('mail_username')) <p class="help-block">{{ $errors->first('mail_username') }}</p> @endif
  69. </div>
  70. <div class="form-group smtp-item @if ($errors->has('mail_password')) has-error @endif">
  71. <label for="mail_password">邮箱密码</label>
  72. <span class="text-muted">(根据实际情况填写你邮箱的密码或第三方客户端授权码)</span>
  73. <input type="password" name="mail_password" class="form-control " placeholder="邮箱认证密码" value="{{ old('mail_password',Setting()->get('mail_password')) }}">
  74. @if ($errors->has('mail_password')) <p class="help-block">{{ $errors->first('mail_password') }}</p> @endif
  75. </div>
  76. <div class="form-group sendmail @if ($errors->has('mail_sendmail')) has-error @endif">
  77. <label for="mail_sendmail">SendMail命令配置</label>
  78. <span class="text-muted">(设置SendMail命令配置)</span>
  79. <input type="text" name="mail_sendmail" class="form-control " placeholder="/usr/sbin/sendmail -bs" value="{{ old('mail_sendmail',Setting()->get('mail_sendmail','/usr/sbin/sendmail -bs')) }}">
  80. @if ($errors->has('mail_sendmail')) <p class="help-block">{{ $errors->first('mail_sendmail') }}</p> @endif
  81. </div>
  82. </div>
  83. <div class="box-footer">
  84. <button type="submit" class="btn btn-primary">保存</button>
  85. <button type="button" class="btn btn-success" id="btn_test_email" >发送测试邮件</button>
  86. </div>
  87. </form>
  88. </div>
  89. </div>
  90. </div>
  91. </section>
  92. @endsection
  93. @section('script')
  94. <div class="modal fade" id="test_email_model" role="dialog">
  95. <div class="modal-dialog" role="document">
  96. <div class="modal-content">
  97. <div class="modal-header">
  98. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  99. <h4 class="modal-title" id="exampleModalLabel">发送测试邮件</h4>
  100. </div>
  101. <div class="modal-body">
  102. <form name="messageForm" id="message_form">
  103. <div class="form-group">
  104. <label for="to_user_id" class="control-label">收件人邮箱:</label>
  105. <input type="email" class="form-control" id="test_send_to" name="sendTo" value="" placeholder="收件人邮箱地址" />
  106. </div>
  107. <div class="form-group">
  108. <label for="message-text" class="control-label">内容:</label>
  109. <textarea class="form-control" id="test_email_content" name="content">你好,这是一封测试邮件。收到邮件后请不要回复!</textarea>
  110. </div>
  111. </form>
  112. </div>
  113. <div class="modal-footer">
  114. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  115. <button type="button" class="btn btn-primary" id="submit_test_email">发送</button>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. <script type="text/javascript">
  121. function show_email_item(){
  122. var mail_dirver = $("#mail_driver").val();
  123. if(mail_dirver == 'smtp'){
  124. $(".smtp-item").show();
  125. $(".sendmail").hide();
  126. }else{
  127. $(".smtp-item").hide();
  128. $(".sendmail").show();
  129. }
  130. }
  131. $(function(){
  132. set_active_menu('global',"{{ route('admin.setting.email') }}");
  133. show_email_item();
  134. $("#mail_driver").change(function(){
  135. show_email_item();
  136. });
  137. $("#btn_test_email").click(function(){
  138. if(confirm('请确认邮件配置项已保存成功?')){
  139. $("#test_email_model").modal('show');
  140. }
  141. });
  142. /*发送测试邮件*/
  143. $("#submit_test_email").click(function(){
  144. var sendTo = $("#test_send_to").val();
  145. var content = $("#test_email_content").val();
  146. $.post('{{ route('admin.tool.sendTestEmail') }}',{sendTo:sendTo,content:content},function(msg){
  147. console.log(msg);
  148. if(msg == 'ok'){
  149. alert('邮件发送成功');
  150. }else{
  151. alert('邮件发送错误:'+ msg );
  152. }
  153. $("#test_email_model").modal('hide');
  154. });
  155. });
  156. });
  157. </script>
  158. @endsection