😎邮件发送增加可以指定邮箱
This commit is contained in:
parent
18e076befa
commit
5c6cfe079c
@ -42,7 +42,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>
|
||||
|
||||
@ -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.GetConfigValueByCode<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")
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user