email.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. {extend name="common/base"/}
  2. <!-- 主体 -->
  3. {block name="body"}
  4. <form class="layui-form p-4">
  5. <h3 class="pb-3">邮箱配置</h3>
  6. <table class="layui-table layui-table-form">
  7. <tr>
  8. <td class="layui-td-gray-2">SMTP地址<font>*</font>
  9. </td>
  10. <td>
  11. <input type="hidden" name="id" value="{$id}">
  12. <input type="text" name="smtp" lay-verify="required" autocomplete="off" placeholder="请输入SMTP服务器地址"
  13. lay-reqText="请输入SMTP服务器地址" class="layui-input" {notempty name="$config.smtp" }
  14. value="{$config.smtp}" {/notempty} style="width:240px;display: inline-block;">
  15. <span
  16. style="color:#999; font-size:12px;">如:QQ邮箱的SMTP服务器地址是smtp.qq.com,163邮箱的SMTP服务器地址是smtp.163.com</span>
  17. </td>
  18. </tr>
  19. <tr>
  20. <td class="layui-td-gray-2">协议端口号<font>*</font>
  21. </td>
  22. <td>
  23. <input type="text" name="smtp_port" lay-verify="required" autocomplete="off" placeholder="请输入端口"
  24. lay-reqText="请输入端口" class="layui-input" {notempty name="$config.smtp_port" }
  25. value="{$config.smtp_port}" {/notempty} style="width:240px;display: inline-block;">
  26. <span style="color:#999; font-size:12px;">如:QQ邮箱的ssl协议方式端口号是465/587,163邮箱的ssl协议方式端口号是465/994</span>
  27. </td>
  28. </tr>
  29. <tr>
  30. <td class="layui-td-gray">邮箱账户<font>*</font>
  31. </td>
  32. <td>
  33. <input type="text" name="smtp_user" autocomplete="off" lay-verify="required" placeholder="请输入邮箱用户名"
  34. lay-reqText="请输入邮箱用户名" class="layui-input" {notempty name="$config.smtp_user" }
  35. value="{$config.smtp_user}" {/notempty} style="width:240px;display: inline-block;">
  36. <span style="color:#999; font-size:12px;">如:gougucms@qq.com</span>
  37. </td>
  38. </tr>
  39. <tr>
  40. <td class="layui-td-gray">邮箱密码<font>*</font>
  41. </td>
  42. <td>
  43. <input type="password" name="smtp_pwd" lay-verify="required" autocomplete="off" placeholder="请输入邮箱密码"
  44. class="layui-input" {notempty name="$config.smtp_pwd" } value="{$config.smtp_pwd}" {/notempty}
  45. style="width:240px;display: inline-block;">
  46. <span style="color:#999; font-size:12px;">
  47. 不一定是登录密码,如QQ邮箱的是第三方授权登录码,要自己去开启,在邮箱的设置->账户->POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务</span>
  48. </td>
  49. </tr>
  50. <tr>
  51. <td class="layui-td-gray">发送人<font>*</font>
  52. </td>
  53. <td>
  54. <input type="text" name="from" autocomplete="off" lay-verify="required" placeholder="请输入要显示的发送者"
  55. lay-reqText="请输入要显示的发送者" class="layui-input" {notempty name="$config.from" } value="{$config.from}"
  56. {/notempty} style="width:240px; display: inline-block;">
  57. <span style="color:#999; font-size:12px;">用于展示给发送方,如:系统管理员</span>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td class="layui-td-gray">显示的邮箱<font>*</font>
  62. </td>
  63. <td>
  64. <input type="text" name="email" lay-verify="required" autocomplete="off" placeholder="请输入要显示的发送者邮箱"
  65. lay-reqText="请输入要显示的发送者邮箱" class="layui-input" {notempty name="$config.email" }
  66. value="{$config.email}" {/notempty} style="width:240px;display: inline-block;">
  67. <span style="color:#999;font-size:12px;">可以不同于上面的账户,用于展示给发送方的邮箱,如:admin@gougucms.com</span>
  68. </td>
  69. </tr>
  70. <tr>
  71. <td class="layui-td-gray">邮件模板</td>
  72. <td><textarea name="template" placeholder="" class="layui-textarea" id="container">{notempty name="$config.template"}{$config.template}{/notempty}</textarea>
  73. </td>
  74. </tr>
  75. </table>
  76. <div class="py-3">
  77. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
  78. <button lay-event="email" class="layui-btn">发送测试</button>
  79. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  80. </div>
  81. </form>
  82. {/block}
  83. <!-- /主体 -->
  84. <!-- 脚本 -->
  85. {block name="script"}
  86. <script>
  87. const moduleInit = ['tool','tinymce'];
  88. function gouguInit() {
  89. var form = layui.form, tool = layui.tool, tinymce = layui.tinymce;
  90. var edit = tinymce.render({
  91. selector: "#container",
  92. height: 300
  93. });
  94. //监听提交
  95. form.on('submit(webform)', function (data) {
  96. data.field.template = tinyMCE.editors['container'].getContent();
  97. let callback = function (e) {
  98. layer.msg(e.msg);
  99. if (e.code == 0) {
  100. parent.layui.tool.close(1000);
  101. }
  102. }
  103. tool.post("/admin/conf/edit", data.field, callback);
  104. return false;
  105. });
  106. $('body').on('click', '[lay-event="email"]', function () {
  107. layer.prompt({
  108. formType: 0,
  109. value: '',
  110. title: '输入接收测试邮件的邮箱',
  111. id: 'email_to'
  112. }, function (value, index, elem) {
  113. var isEmail = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
  114. if (value.length < 6 || !(isEmail.test(value))) {
  115. layer.tips('请正确输入邮箱', elem);
  116. return false;
  117. }
  118. $.ajax({
  119. url: "/home/api/email_test",
  120. data: { email: value },
  121. type: "post",
  122. beforeSend: function () {
  123. // 禁用按钮防止重复提交
  124. $("#email_to input").val('');
  125. },
  126. success: function (e) {
  127. layer.msg(e.msg);
  128. if (e.code == 0) {
  129. layer.close(index);
  130. }
  131. }
  132. })
  133. });
  134. return false;
  135. })
  136. }
  137. </script>
  138. {/block}
  139. <!-- /脚本 -->