diff --git a/Infrastructure/OptionsSetting.cs b/Infrastructure/OptionsSetting.cs index afd3dff..c6cf6f0 100644 --- a/Infrastructure/OptionsSetting.cs +++ b/Infrastructure/OptionsSetting.cs @@ -24,6 +24,7 @@ namespace Infrastructure public string Password { get; set; } public string Smtp { get; set; } public int Port { get; set; } + public string Signature { get; set; } } /// /// 上传 diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json index 3789b8b..33712f7 100644 --- a/ZR.Admin.WebApi/appsettings.json +++ b/ZR.Admin.WebApi/appsettings.json @@ -47,7 +47,8 @@ "Password": "123456", //协议 "Smtp": "smtp.qq.com", - "Port": 587 + "Port": 587, + "Signature": "系统邮件,请勿回复!" }, //redis服务配置 "RedisServer": { diff --git a/ZR.Common/MailHelper.cs b/ZR.Common/MailHelper.cs index 3f52ce9..f3984be 100644 --- a/ZR.Common/MailHelper.cs +++ b/ZR.Common/MailHelper.cs @@ -27,10 +27,13 @@ namespace ZR.Common /// public int Port { get; set; } = 587; /// + /// 邮件签名 + /// + public string Signature { get; set; } + /// /// 是否使用SSL协议 /// public bool UseSsl { get; set; } = false; - public string mailSign = @"邮件来自C# 程序发送"; private readonly MailOptions mailOptions = new(); public MailHelper() @@ -56,7 +59,7 @@ namespace ZR.Common } /// - /// 发送一个人 + /// 发送一个 /// /// /// @@ -105,8 +108,8 @@ namespace ZR.Common //收件人 message.To.AddRange(toAddress); message.Subject = subject; - //message.Date = DateTime.Now; - + message.Date = DateTime.Now; + //创建附件Multipart Multipart multipart = new Multipart("mixed"); var alternative = new MultipartAlternative(); @@ -120,14 +123,14 @@ namespace ZR.Common alternative.Add(Html); } //文本内容 - if (!string.IsNullOrEmpty(text)) + //if (!string.IsNullOrEmpty(text)) + //{ + var plain = new TextPart(TextFormat.Plain) { - var plain = new TextPart(TextFormat.Plain) - { - Text = text + "\r\n\n\n" + mailSign - }; - alternative.Add(plain); - } + Text = text + "\r\n\n\n" + mailOptions.Signature + }; + alternative.Add(plain); + //} //附件 if (!string.IsNullOrEmpty(path)) diff --git a/ZR.Common/ZR.Common.csproj b/ZR.Common/ZR.Common.csproj index f3df98d..be78c30 100644 --- a/ZR.Common/ZR.Common.csproj +++ b/ZR.Common/ZR.Common.csproj @@ -8,7 +8,7 @@ - +