From 78aa48a97551dbfcc30dc668c15dc0d3965d5a64 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Fri, 1 Jul 2022 20:01:40 +0800
Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E9=82=AE=E4=BB=B6=E5=8F=91?=
=?UTF-8?q?=E9=80=81=E6=96=B0=E5=A2=9E=E7=AD=BE=E5=90=8D=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Infrastructure/OptionsSetting.cs | 1 +
ZR.Admin.WebApi/appsettings.json | 3 ++-
ZR.Common/MailHelper.cs | 25 ++++++++++++++-----------
ZR.Common/ZR.Common.csproj | 2 +-
4 files changed, 18 insertions(+), 13 deletions(-)
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 @@
-
+