Browse Source

邮件配置

懒得勤快 5 years ago
parent
commit
3e842d0133

+ 5 - 6
src/Masuit.MyBlogs.Core/Common/CommonHelper.cs

@@ -16,9 +16,8 @@ using System.Linq;
 using System.Net;
 using System.Text;
 using System.Threading;
+
 #if !DEBUG
-using Masuit.MyBlogs.Core.Models.ViewModel;
-using Masuit.Tools.Models;
 #endif
 
 namespace Masuit.MyBlogs.Core.Common
@@ -197,11 +196,11 @@ namespace Masuit.MyBlogs.Core.Common
 #if !DEBUG
             new Email()
             {
-                EnableSsl = true,
+                EnableSsl = bool.Parse(SystemSettings.GetOrAdd("EnableSsl", "true")),
                 Body = content,
-                SmtpServer = EmailConfig.Smtp,
-                Username = EmailConfig.SendFrom,
-                Password = EmailConfig.EmailPwd,
+                SmtpServer = SystemSettings["SMTP"],
+                Username = SystemSettings["EmailFrom"],
+                Password = SystemSettings["EmailPwd"],
                 SmtpPort = SystemSettings["SmtpPort"].ToInt32(),
                 Subject = title,
                 Tos = tos

+ 2 - 2
src/Masuit.MyBlogs.Core/Controllers/SystemController.cs

@@ -185,13 +185,13 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="port"></param>
         /// <param name="to"></param>
         /// <returns></returns>
-        public ActionResult MailTest(string smtp, string user, string pwd, int port, string to)
+        public ActionResult MailTest(string smtp, string user, string pwd, int port, string to, bool ssl)
         {
             try
             {
                 new Email()
                 {
-                    EnableSsl = true,
+                    EnableSsl = ssl,
                     Body = "发送成功,网站邮件配置正确!",
                     SmtpServer = smtp,
                     Username = user,

+ 1 - 1
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -43,7 +43,7 @@
         <PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.1.0" />
         <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
         <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
-        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.1.1" />
+        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.1.2" />
         <PackageReference Include="WilderMinds.RssSyndication" Version="1.6.0" />
         <PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.14" />
         <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.50" />

+ 0 - 30
src/Masuit.MyBlogs.Core/Models/ViewModel/EmailConfig.cs

@@ -1,30 +0,0 @@
-using Masuit.MyBlogs.Core.Common;
-
-namespace Masuit.MyBlogs.Core.Models.ViewModel
-{
-    /// <summary>
-    /// 邮箱配置
-    /// </summary>
-    public static class EmailConfig
-    {
-        /// <summary>
-        /// smtp服务器地址
-        /// </summary>
-        public static string Smtp => CommonHelper.SystemSettings["SMTP"];
-
-        /// <summary>
-        /// 发送邮箱用户名
-        /// </summary>
-        public static string SendFrom => CommonHelper.SystemSettings["EmailFrom"];
-
-        /// <summary>
-        /// 发送邮箱密码
-        /// </summary>
-        public static string EmailPwd => CommonHelper.SystemSettings["EmailPwd"];
-
-        /// <summary>
-        /// 收件人
-        /// </summary>
-        public static string ReceiveEmail => CommonHelper.SystemSettings["ReceiveEmail"];
-    }
-}

+ 6 - 0
src/Masuit.MyBlogs.Core/bundleconfig.json

@@ -94,5 +94,11 @@
     "inputFiles": [
       "wwwroot/Scripts/jquery_3.4.1.js"
     ]
+  },
+  {
+    "outputFileName": "wwwroot/ng-views/controllers/system.min.js",
+    "inputFiles": [
+      "wwwroot/ng-views/controllers/system.js"
+    ]
   }
 ]

+ 10 - 1
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/system.js

@@ -86,7 +86,8 @@
 			user: $scope.Settings.EmailFrom,
 			pwd: $scope.Settings.EmailPwd,
 			port: $scope.Settings.SmtpPort,
-			to: $scope.Settings.ReceiveEmail
+			to: $scope.Settings.ReceiveEmail,
+			ssl:$scope.Settings.EnableSsl
 		}).then(function(res) {
 			if (res.data.Success) {
 				swal(res.data.Message,'','success');
@@ -135,6 +136,14 @@
 		}
 	}
 
+	$scope.EmailEnableSsl= function() {
+		if($scope.Settings.EnableSsl=="true") {
+			$scope.Settings.EnableSsl="false";
+		} else {
+			$scope.Settings.EnableSsl="true";
+		}
+	}
+
 	$scope.CloseSite= function() {
 		if($scope.Settings.CloseSite=="true") {
 			$scope.Settings.CloseSite="false";

File diff suppressed because it is too large
+ 0 - 0
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/system.min.js


+ 0 - 3
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/system/email.html

@@ -22,9 +22,6 @@
         }
 </style>
 <div class="row">
-    <h3 class="text-center" ng-show="files.length<=0">
-        暂无日志文件
-    </h3>
     <div class="col-md-1 col-sm-2 col-xs-3 file-icon" ng-repeat="item in files" ng-dblclick="view(item.path)">
         <img src="/Assets/images/file.png" class="img img-responsive img-thumbnail img-rounded"/>
         <p class="size24 text-center" style="word-wrap: break-word;">{{item.filename}}</p>

+ 7 - 0
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/system/home.html

@@ -129,6 +129,13 @@
                 <input type="text" class="form-control" ng-model="Settings.SmtpPort" />
             </div>
         </div>
+        <div class="input-group">
+            <span class="input-group-addon el-switch" style="text-align: left">
+                <span>启用SSL:</span>
+                <input type="checkbox" name="switch" ng-checked="Settings.EnableSsl=='true'">
+                <span class="el-switch-style" ng-click="EmailEnableSsl()"></span>
+            </span>
+        </div>
         <div class="input-group">
             <span class="input-group-addon">接收网站通知邮箱:</span>
             <div class="fg-line">

Some files were not shown because too many files changed in this diff