smtp.php 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2017-03-15 21:16
  7. */
  8. /**
  9. * @var $this yii\web\View
  10. * @var $model common\models\Options
  11. */
  12. use backend\widgets\ActiveForm;
  13. use common\widgets\JsBlock;
  14. use yii\helpers\Url;
  15. $this->title = Yii::t('app', 'SMTP Setting');
  16. $this->params['breadcrumbs'][] = Yii::t('app', 'SMTP Setting');
  17. ?>
  18. <div class="row">
  19. <div class="col-sm-12">
  20. <div class="ibox float-e-margins">
  21. <?=$this->render('/widgets/_ibox-title');?>
  22. <div class="ibox-content">
  23. <?php $form = ActiveForm::begin(); ?>
  24. <?php
  25. $template = "{label}\n<div class='col-sm-8'>{input}\n{error}</div>\n{hint}<div class='col-sm-2'><span class='tips'> {{%TIPS%}}</span></div>";
  26. ?>
  27. <?= $form->field($model, 'smtp_host', ['template' => str_replace("{{%TIPS%}}", "<i class='fa fa-info-circle'></i> " . yii::t('app', 'smtp.xxx.com'), $template)]) ?>
  28. <div class="hr-line-dashed"></div>
  29. <?= $form->field($model, 'smtp_port', ['template' => str_replace("{{%TIPS%}}", "<i class='fa fa-info-circle'></i> " . yii::t('app', '25/465/587'), $template)]) ?>
  30. <div class="hr-line-dashed"></div>
  31. <?= $form->field($model, 'smtp_username', ['template' => str_replace("{{%TIPS%}}", "<i class='fa fa-info-circle'></i> " . "x@xx.com", $template)]) ?>
  32. <div class="hr-line-dashed"></div>
  33. <?= $form->field($model, 'smtp_password', ['template' => str_replace("{{%TIPS%}}", "", $template)])->textInput() ?>
  34. <div class="hr-line-dashed"></div>
  35. <?= $form->field($model, 'smtp_nickname', ['template' => str_replace("{{%TIPS%}}", "<i class='fa fa-info-circle'></i> " . "xx", $template)])->textInput() ?>
  36. <div class="hr-line-dashed"></div>
  37. <?= $form->field($model, 'smtp_encryption', ['template' => str_replace("{{%TIPS%}}", "<i class='fa fa-info-circle'></i> " . "tls/ssl", $template)]) ?>
  38. <div class="hr-line-dashed"></div>
  39. <div class="form-group">
  40. <div class="col-sm-4 col-sm-offset-2">
  41. <button class="btn btn-primary" type="submit"><?= Yii::t('app', 'Save') ?></button>
  42. <button id="test" class="btn btn-success" type="button"><?= Yii::t('app', 'Test') ?></button>
  43. <button class="btn btn-white" type="reset"><?= Yii::t('app', 'Reset') ?></button>
  44. </div>
  45. </div>
  46. <?php ActiveForm::end(); ?>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. <?php JsBlock::begin(); ?>
  52. <script>
  53. $(document).ready(function () {
  54. $("#test").click(function () {
  55. layer.msg('<?=Yii::t('app', 'Loading, hold on please...')?>', {icon: 16, 'time': 0});
  56. $.ajax({
  57. url: '<?=Url::to(['test-smtp'])?>',
  58. method: 'post',
  59. data: $("form").serialize(),
  60. success: function (data) {
  61. if( typeof data == "object" && data.hasOwnProperty("code") && data.code==0) {
  62. layer.msg("<?=Yii::t('app', 'Success')?>");
  63. }else{
  64. layer.msg(data)
  65. }
  66. },
  67. error: function (jqXHR, textStatus, errorThrown) {
  68. layer.msg(jqXHR.responseJSON.message);
  69. },
  70. complete: function () {
  71. layer.closeAll('loading');
  72. }
  73. });
  74. return false;
  75. });
  76. })
  77. </script>
  78. <?php JsBlock::end(); ?>