Explorar el Código

😎邮件发送增加可以指定邮箱

zuohuaijun hace 1 año
padre
commit
20ec0264c3

+ 1 - 1
Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj

@@ -39,7 +39,7 @@
     <PackageReference Include="SqlSugarCore" Version="5.1.4.169" />
     <PackageReference Include="SSH.NET" Version="2024.1.0" />
     <PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.6" />
-    <PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1106" />
+    <PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1108" />
     <PackageReference Include="UAParser" Version="3.1.47" />
     <PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
   </ItemGroup>

+ 6 - 2
Admin.NET/Admin.NET.Core/Service/Message/SysEmailService.cs

@@ -29,15 +29,19 @@ public class SysEmailService : IDynamicApiController, ITransient
     /// </summary>
     /// <param name="content"></param>
     /// <param name="title"></param>
+    /// <param name="toEmail"></param>
     /// <returns></returns>
     [DisplayName("发送邮件")]
-    public async Task SendEmail([Required] string content, string title = "")
+    public async Task SendEmail([Required] string content, string title = "", string toEmail = "")
     {
         var webTitle = await _sysConfigService.GetConfigValue<string>(ConfigConst.SysWebTitle);
         title = string.IsNullOrWhiteSpace(title) ? $"{webTitle} 系统邮件" : title;
         var message = new MimeMessage();
         message.From.Add(new MailboxAddress(_emailOptions.DefaultFromEmail, _emailOptions.DefaultFromEmail));
-        message.To.Add(new MailboxAddress(_emailOptions.DefaultToEmail, _emailOptions.DefaultToEmail));
+        if (string.IsNullOrWhiteSpace(toEmail))
+            message.To.Add(new MailboxAddress(_emailOptions.DefaultToEmail, _emailOptions.DefaultToEmail));
+        else
+            message.To.Add(new MailboxAddress(toEmail, toEmail));
         message.Subject = title;
         message.Body = new TextPart("html")
         {